As you say, you can't put wildcards in
/etc/hosts. It just doesn't work.
That really leaves you with one option: mangle the actual DNS manually. There are several ways you could do this but two spring to mind as the best options...
You could run a fully-flegded DNS server locally. This can be a good idea if your internet connection is slow and you'd like all devices on the network to proxy through this server, or you run many domains that you want to override, or some other reason you want to step into the first ring of hell... It won't take a week, but it does requires learning stuff.
Or you could just override
dnsmasq's settings. Ubuntu through
network-manager is already running a sort of DNS proxy in the form of
dnsmasq and you can tell it to override various domains, quite easily. Here's how I'd route
*.thepcspy.com (my domain) to
echo address=/thepcspy.com/127.0.0.1/ | sudo tee -a /etc/NetworkManager/dnsmasq.d/local
sudo service network-manager restart
Then to test:
$ nslookup thepcspy.com
And a subdomain:
$ nslookup testing.thepcspy.com
To revert these changes, just edit (or delete)
/etc/NetworkManager/dnsmasq.d/local and restart