The most usable function I found for my mouse thumb button is actually Minimize window. When you combine it with Alt+Tab, it does wonders for fast window switching. Under Windows it's trivial to configure this within Logitech Options. While not as easy in Linux, it's actually not that hard either.
Since the Thumb button on most Logitech's devices is not a mouse button but a key combination, we can use Ubuntu's built-in Keyboard utility instead of remapping buttons. Or we can do it from command line equally easy:
gsettings set org.gnome.desktop.wm.keybindings minimize "['<Primary><Alt>Tab']"
If you really want to have quick switching, you might want to also disable animations:
gsettings set org.gnome.desktop.interface enable-animations false
With those two changes you have your thumb button configured.
PS: And yes, this works for MX Master too.