There is no need to make this more complicated than it needs to be. We would do it just like before Octoprint...no raspi or octoprint needed.
What controller does your printer have? You can feed it external power via the USB port or other board pins
If you have open I/O pin, then assign that one to be PS_ON pin.
As long as the controller is on, then issuing an M80 gcode will trigger that pin and if you have a 5V relay to control the main board power, it will trigger.