Is there a way to block specific hostnames from being accessible in Virtualbox guests?
All the normal methods of blocking websites for physical machines are possible with VirtualBox guests as well. You can:
Modify the guest's hosts file and direct the given requests to the IP(s) of your choice there.
Set up a local DNS server and route the guest's DNS requests to that server (which, again, would resolve those certain requests to any IP(s) of your choice.)
Set up a proxy server to block requests to those addresses from the guest.
Regarding the DNS and proxy server solutions, either of these servers could be on the guest itself, another virtual machine, the host or another physical machine on the network.
It is probably worth mentioning that you don't need to give guests Internet access in the first place — you can use Host-Only network adapters, for instance.
What's the best way to accomplish this?
For minimal security, solutions that rely on the guest machine are probably less secure than those that rely on a separate virtual machine, the host or another physical machine.
Other than that, the best solution probably depends greatly on your network and why/how you wish to block those addresses.