Have you considered changing the sens directly in tf2 via rcon instead of changing it system wide in libinput? You could easily make it crossplatform that way, and also keep m_rawinput on. The game client serves rcon if you launch with
-usercon +rcon_password "whatever" +ip 127.0.0.1 +net_start
You could use something like https://github.com/n0la/rcon or https://python-valve.readthedocs.io/en/latest/rcon.html in your script, or, if you deem those clients too bloated, cap a packet, look at how it changes when you send a different value in the sensitivity command, and just send the raw bytes with nc.