Ice
macOSIce is a powerful menu bar management tool. While its primary function is hiding and showing menu bar items, it aims to cover a wide variety of additional features to make it one of the most versatile menu bar tools available.
If you're looking for an alternative to Bartender for some reason, you might want to take a look at Ice. It's not nearly as comprehensive, but it basically does what you want it to do, namely hide items in the menu bar when you don't need them. Another good alternative seems to be Hidden Bar. Both FOSS. Give them a try.