Let us differentiate Government jobs from public sector jobs first. They are not the same.
The public sectors have majority holdings by the government but their employees are governed by a separate set of rules and pay. They are quite autonomous in many aspects. The jobs in these categories are Banks, IITs, IIMs, Universities, BHEL, BEL, etc. Many of these jobs don’t have transfers because all the employees are located in the same place.
There are only a few government jobs where you can’t be transferred out of the city. The best example is the Secretariat Services of Central and State Governments. These officers are also not transferred out of the Delhi/State capital and they spend their entire life in a single city.
If you thinking about Group A service, the best option is IRS where you can spend almost 70-80% of the time in the same station like Delhi or Mumbai in your career. I know some IRS officers who are continuously staying in Delhi for more than 20 years.