It's possible that your firewall (e.g. the Cloud Shell Machine) is blocking Python from connecting via port 8883. Can you try calling the cloudiot_pubsub_example_mqtt_device.py
script with the port set to 443, e.g.
python <your_existing_parameters> --mqtt_bridge_port=443
You may also want to try using the HTTP device sample to publish messages as it also doesn't use port 8883, which may be blocked on your network.
In my tests, I was only able to run the exercise from the Google Cloud Shell after setting my port to 443, this hopefully will resolve the issue for you.
Note If you're encountering issues with verifying the server certificate, you need to download the Google root certificate by calling:
wget https://pki.google.com/roots.pem
Update You may also want to try to set the Python version in your virtual environment to Python 2 by setting up the virtual environment as:
virtualenv env --python=python2