It depends on your network.
The easiest way would be to remove the default gateway from the host's settings, but this may not an option in a corporate network.
Another option would be to block the hosts vmkernel network on your firewall.
Normally you would do this on a networking level. You have a management network for ESXi, that VLAN usually shouldn't be allowed to go outside.
How? Can you show me a tutorial about it?
If you have a firewall in your environment just go there and block ESXi management IP this is the address which resides on vmk0.
And if your VMs uses same subnet with mgmt subnet is. then do not block all subnet.
And if you remove gateway ip of vmk0. Your mgmt packets cannot span between vlans. So that the best option is do it on firewall.
Can it cause any problem for VMs?
On Esxi - Remove the nameserver from /etc/resolv.conf file to Block Internet Connectivity
and On Vm - You can add DNS Record