It should be possible using the environment variable PROMPT_COMMAND: the content of this variable is executed as a regular Bash command just before Bash displays a prompt. You can find an example
here. You can easily adapt the code to put a conditional statement which checks the current directory name and its parents.
Note: before changing the value of PROMPT_COMMAND, look at the current one. Usually it contains the command to set the dynamic title of the terminal windows.