Is it safe to replace hardware while a PC is suspended to RAM?
No, as Toryan already wrote, a PC in sleep mode is still powered on.
Specifically:
Can you unplug an external hard disk without losing data?
If the OS flushed the disk cache prior to dropping to sleep mode: Probably yes.
If is was not done and you still are halfway though a change on the disk: No.
Can you replace components like a drive or a PCI-express card?
Replacing a PCI-e card on a powered-on consumer motherboard is a really bad idea. Even ignoring the risk of shorting things when plugging and unplugging cards on a powered on computer, you also run into initialisation problems. Normally a computer boots, detects hardware and configures it for usage. When the OS is already booted then the all devices are already configured. Adding new hardware will require this new device to catch up.
This is possible, but your OS needs to support it. (e.g. this is why you can plug in express-card, thunderbolt or USB devices). I have serious doubt about comsumer OS's and support for adding, let alone removing PCI-e cards.
SATA and SCSI drives are an exception to this. SCSI support hotplugging. As does SATA in AHCI mode (AHCI is normal SATA mode, as opposed to ancient IDE emulation mode).
(I don't know why one would require this, but I'm curious)
For disks the answer is easy. A failed drive can be replaced without bringing the server down. This works perfectly in combination with RAID. For SoHO tasks: Just power it down.
I'm especially interested in Linux, but I don't know if the OS matters.
The OS matter because it needs support to actually use the new devices. Or support to remove them. Which is something you would need to do before sleep mode. (Much akin to how you need to use safe removal for USB pen drives before unplugging them). If your PC is already in sleep mode then you are to late for this.
1Really, don't. No benefit, high risks – mveroone – 2013-12-24T10:28:40.080