How can I safely extend a wire in my electrical panel?
You should check with your local inspection agency.

Different locales use different revisions of the code. They also may have their own addenda to the NEC. Furthermore, inspector interprets the code differently. 

With all that in mind: 


It looks like 312.8 is the relevant section of the NEC. 
Mike Holt seems certain that wire nuts in breaker panels are OK. See http://www.youtube.com/watch?v=cHi42Gzydh0