I use iTerm2 and have different profiles for different directories/remote hosts. iTerm switches the background colour automatically for me. I'm sure other terminal emulators would have similar features.
https://bsago.me/tech-notes/change-ssh-background-colour-wit....