there can be few potential solutions:
1. You need to create VM machine with startup script that will run your python code. Then, create a VM image, and setup Instance Managed Group together with Load Balancer, configured for serving WebSocket traffic.
It will allow you you have 0 count of instances when you don't have any traffic, and scale to N instances, based on CPU or Traffic load.
WebSocket application can use tiny smallest VMs, and by tuning LoadBalancer config it will allow you to spend few tens of dollars to serve hundreds of thousands active connections.
2. as https://stackoverflow.com/a/79799060/5914649 Doug answered, CloudRun will allow you to hide LoadBalancer complexity and use auto-scale from the box (CloudRun specifically created for it), but you'll need to setup a proper Docker container>
2a. Also, there is a possibility to combine CloudRun + Load balancer: https://medium.com/@vilyamm/how-to-publish-your-cloud-run-service-on-cloudflare-using-a-static-ip-497f52e78f91
this topic was created specifically for WebSocket traffic. but you can get ideas to setup +- the same, just Managed Group instead of Serverless