You can use relays from a controller board to switch a router or vacuum on and off.
The extruder and heated bed have other considerations that might make them more difficult to use. For one, they are 12V instead of 5V so they might cook a 5V relay, and also they are intended to be used with temperature control, so the fake thermistor has to be set properly for it to decide to turn on. Also, Marlin has thermal runaway detection, where if it turns on and does not detect the temperature changing, then it thinks maybe the thermistor has come loose, and it will panic and shut everything down. You would need to make sure this feature is disabled.
I think a simpler way would be to use SPINDLE_LASER_ENABLE and map one of the 5V pins, and then M3 and M5 will work, which CAM typically generates in reasonable places (like switching tools).