Another option would be to add software PWM to any unused GPIO pin that can currently be used by M42 depending on the PWM frequency wanted this could add too much overhead though.
The overhead would be high unless the PWM resolution were limited to 1ms or the timing were done in the step ISR, which I would rather avoid because of the impact on maximum step generation speed.
Regarding deciding if a heater output is used or not, rather than a new M code, why not just allow all heaters that are not added to a tool to be used as PWM?
For safety reasons I would rather the user made a definite statement that there is no heater attached to the pin. But perhaps we don't need a new M code, we could add an option to M305 instead.