Is there any way to retrieve data from a PIC16F877 if VCC and GND are shorted? I want to get the existing program and load it into a new device.
If the Vcc and GND are internally shorted within the IC, there is no simple solution.
Cutting open the IC to access the internal die, then using suitable equipment to correct the short, is fine as a theoretical exercise but not worthwhile in practice.
If the short is on the circuit board, simply desolder the part carefully, solder it into a fresh PCB, and you would have access to all standard functions of the microcontroller.
Edit: The following may not be relevant to the original question, as pointed out by @DaveTweed.
Capturing the inbuilt program, -as you state-, is still not so simple: Even if you could extract the binary code as a hex file, that then would need to be decompiled to assembly language instructions, then interpreted to make sense of it in high level pseudocode.
The solution for modifying the existing program, if required at all, is way more complex and expensive than might be assumed.