I tried this on Ubuntu 18.10 and it only worked with PROMPT_COMMAND in ~/.bashrc.
And if you override PROMPT_COMMAND, the behavior of the title changes slightly. I decided to change only if necessary:
t() {
TITLE="$@"
PROMPT_COMMAND='echo -ne "\033]0;${TITLE}\007"'
}
enter image description here