I have my eye on this, see
github.com/LinuxCNC/linuxcnc/issues/2532
Until that change is implemented, you can do what you need (probably) in HAL.
The simplest approach is just to "and2" the digital output with the machine.is-on HAL pin before sending it to the destination.
This probably needs to be combined with a startup G-code which turns off the output, or it will go live at moment the machine comes back on again.
A more complex interaction could be set up with combinations of the flipflop, toggle and edge HAL components.
Or it might be best to construct a custom HAL component with the following behaviour:
If the machine is turned off the pin takes a settable default state
if the machine is turned on, the pins retain the default state (or take a different default state?)
If the input toggles from low to high and the machine is on - the output goes high
if the input toggles from high to low and the machine is on - the output goes low.
This is not entirely the same as the desired behaviour, as I think that if the output was set high before the machine-off it needs to be set off before setting on to trigger a change to the output described above.