Yes, but you don't become a higher rank, necessarily, because Captain gets treated as "starship commander" a lot in Trek, rather than acknowledging an officer and perhaps daring to give them some sort of recognition for being so good at their job and their contributions.
Maybe even a promotion of some kind. I know, it's a weird thought.
I think this another example of projecting a modern world sensibility onto a future world.
Rank doesn't really matter quite as much in Trek, and "Captain" in Starfleet... by and large *IS* "Starship Commander". If you don't want to command a starship, there's little reason to become a Captain, same for full Commander.
That being said, people can and do reach higher rank without necessarily going on to command a starship. Scotty is an example, being a Captain but... still just being an engineer just in charge of more engineering stuff.
We've learned time and again that Star Trek doesn't work the same way modern day does. People think differently. People aren't doing things in Starfleet for money or for recognition. They're doing it because they want to do it, and they want to contribute. Rank is really more of a formality, and while yeah sure it's cool to increase in rank... and... people do in fact increase in rank... it's also not that big of a deal.
But to circle back to the point, yes, MOST people will probably top out at Lt. Commander. Commander and Captain are fairly specific things in Starfleet, and they are generally directly related to... command. If you're a bangin' Stellar Cartographer, and you want to keep doing Stellar Cartography... you would probably move up to Lt. Commander. Being a Commander Stellar Cartographer would move you up in position to be less doing Stellar Cartography, more running teams of Stellar Cartographers who are doing the Stellar Cartography.
Swinging back to a modern-day, real-world perspective... this is an issue I see often in the private sector. It's something I deal with directly... i'm in management, involved with hiring/promoting management. The problem is that we have set up a system where "Advancement" for most roles means "People Management", and... in my experience... most people aren't really suited for people management. FAAAAARRR too often, a person may be exceptional at X Role, and then they want to advance, which places them in a Management role, managing people doing X Role. As it turns out, which should be no surprise to people but it is, being good at X Role doesn't NOT necessarily translate to management. It's an entirely different skillset. I work heavily with sales. We have this habit (as do most companies) of promoting really good salespeople to management roles. Sometimes it works. Sometimes it doesn't. Being really good at sales has very little to do with being really good at management.
In terms of Star Trek... there's no particular reason to keep advancing, because money isn't really a concern. The reason most people want to advance in their careers is to make more money. In Starfleet, one would generally want to advance in their career because they want to take on a new role. If somebody is happy doing the job they are doing and they're doing it well? Awesome! Keep it up!