Someone did control PF using the stick C's built in IRLED but can't remember how.
So there's existing integration for that into MakeCode (which is also blockly based I believe) and then also the regular Arduino lib. Also the whole IR protocol is documented officially by Lego. But the MakeCode integration seems JS based (not Python based), and I also don't see a good waqy to integrate the Arduino lib into the UiFlow custom component editor. So probably whoever did this before just wrote regular Arduino code for the M5Stick using the Arduino library.
If I ever find a lot of time I might try to reverse engineer the existing code, and redo as a custom block in UIFlow, but not sure if this will ever happen ;-)
There are instructions on how to build NXT>PF leads but I haven't had time to revisit.
I'm also gonna look into that :-)