Despite the claims of other answers, this is possible.
The solution that springs to mind is to add a reverse proxy which can forward on requests to the web server after matching the host. Indeed this is exactly the kind of thing services like Cloudflare offer.
It would not be possible to do this using simple firewall rules because a connection needs to be made to the IP address before the domain name is communicated. (Id not recommend it but it might be possible to inspect the packet contents and look for the domain name header and you could then block on this - conceivably using iptables/ufw - but this could leave open connections to the webserver, and in any event would not happen before the web server sees the traffic)