I think it should not be hard. You define a output so you have a gcode command for that pin to change it. Add the default state command in run on activate script in g-codes for printer. Normally off I'd say.
Now add input with "Run G-Code on change mode" and select the edge rising or falling to trigger it.
In the script you check if output is on or of and trigger the opposite. Testing is done by
get_gpio_state(gpioName)
Returns the state of a gpio pin with given name (from Global Setting->GPIO Pins, not BCM pin number). Works for digital outputs and inputs.
So assuming you named output onoffRelay it would look like this
@gpio onoffRelay toggle
This changes output every time you press the button.