Can you replace a laptop battery in hibernation mode?

It depends if its plugged in or not. If the battery is currently the laptops only power source then the laptop would just shut off.

It would be best to turn off the laptop first, but it probably wont hurt it. The worst thing that would probably happen is you'd have static electricity which might stop the computer from powering on until you cleared it out. You can do this by holding down the power button with the battery and power cord unplugged for 10 seconds.