Klipper has this: Display_template for fan control
Another example: TMC2240 use temp for fan control
It should cover most of the cases where one needs “custom” behaviour
Otherwise, regarding the PSU’s Fan, normally it is enough to use a thermostat to do so.
Internally, it is possible to either attach it to the MOSFETs or to the inductor coil.
-Timofey