Location-aware hostname resolution
Maybe ControlPlane can help you.

ControlPlane allows you to build configuration profiles, contexts in
ControlPlane lingo, for your Mac based on where you are or what you
are doing.
ControlPlane determines where you are or what you are
doing based on a number of available evidence sources and then
automatically reconfigures your Mac based on your preferences.
Evidence sources can include your current location, visible WiFi
networks, attached USB devices, running applications and more.  You
can even write your own evidence sources using shell scripts!