How can I extend my deck posts to support a pergola?
To accomplish the join I'd acquire some 1/4" by 3-1/2" by 24" steel plates and let them into opposing sides of the posts to act as gussets. I'd use countersunk flat-head sleeve bolts, piloted accurately and minimally, to sandwich the whole works. 

Be sure to consider whether the existing posts are adequately anchored, as there will be substantial torque applied to them at their bases. It doesn't matter how well you attach the extensions to floppy posts.

That said, I think your plan seems flawed. A pergola creates some fairly unique structural concerns, namely the lack of diagonal bracing that a conventional roof would provide, as well as increased wind drag. 

I'd be replacing your 4x4 posts with 6x6 posts that run all the way through. They'll do the job much better than spliced 4x4s, and they'll probably be more appropriate from an aesthetic standpoint, depending on your design. You don't want chicken legs under your nice new pergola.

If you elect not to do that, consider substantial diagonal bracing below the ceiling line connecting the posts to the primary horizontal members of your design in appropriate directions (where connection to a fixed structure doesn't provide support).