This is called ICP In Circuit Programming, and you can do it so long as your programmer can waggle those pins. This is usually possible if those pins are used as outputs and only connected to other inputs.
If the pins are used as inputs, that is connected to an output of another device then you have to make sure that the other device's output can be over ridden, tri stated or in some other way disabled. One way is to have a removable link.