The HOSTS file is nothing but a rudimentary (local only) DNS mechanism.
A good way to achieve what you're asking for is to set up the DNS server in Windows; it's included with all Windows server versions AFAIK. Set up A records for mail.domain1.com and mail.domain2.com with their respective local server (LAN) IP addresses, and forwarders to your usual name servers for anything not set up on that DNS server. You then set the network adapter on each server to use your new DNS servers. You can set this up on each Windows server - you could set it up on only one server but probably better to have it set up on (at least) all Windows servers that are running SM, and they can reference each other as a backup. It's simpler than it looks at first glance. This should solve the problem for you.
You could alternatively set up "loopback" addresses in your firewall (e.g. Sonicwall), if it allows this, but the DNS server setup mentioned above is more "elegant" IMO, because it's more "self-contained," and should work even if there are issues with the firewall.
Happy to give you more info if you need it.