Is it possible to choose which OS will be loaded using a hardware switch?
You're going to need to write your own grub2 module, interface with the BIOS to get the raw fan speed information, and use that to interpret and process the results. Obviously GRUB doesn't know or care about your fan speed and you won't be able to do it natively without writing some code.
A better solution would be to install the bootloader (just the bootloader, nothing more) to a USB stick. You can use GRUB2 or BOOTMGR - it doesn't matter.
The PC is then configured to load from USB first, and when this USB stick is inserted in the PC, it will boot into Ubuntu; whereas the local disk is configured to boot into Windows. i.e. the presence or absence of the USB will determine which OS your PC boots into.
At that point, it's a simple matter of using a modified USB cable with a switch on one of the VCC lines. If it's active, the USB stick will appear to the BIOS and it will boot from the USB's copy of GRUB booting into Ubuntu. If the switch is off, the PC will load "normally" from the local disk, booting into Windows.
You are of course free to disguise the USB stick, the modified USB cable, and the VCC switch inside a box as a single, standalone unit. It's way cooler than your PWM idea because you literally just stick it in your USB port and you're good to go.