You don't make your question very clear - if you mean can you write to program memory from within a program, you can on certain PIC's (the 16F87x series for example). As this is totally internal, I presume that it could do so even for a protected PIC.
Using an external programmer you have to erase the device, then remove the code protection, before you can program it.
Presumably you have a code protected device you want to modify?, obviously being able to do so would make code protection a waste of time. If you've got the right to alter the code, you will have the source code (or at least the HEX file) and can alter it at that level.