You probably need to do something along the lines of:
Connect the relay to an appropriate pin
Configure the pin to be high during make menuconfig
Then flash the new firmware
Setup the needed macros
[output_pin power_detect]
# Pull the pin initially high after starting Klipper
pin: PC12
value: 1
shutdown_value: 0
[gcode_macro POWER_ON]
description: Turn on the printer via the relay
gcode:
SET_PIN PIN=power_detect VALUE=1
[gcode_macro POWER_OFF]
description: Turn off the printer via the relay
gcode:
SET_PIN PIN=power_detect VALUE=0