This answer is US centric.
For a lot of reasons, including some legal ones, this would be difficult to do as a matter of policy in the US. The legal reasons have to do with the fact that a person's employment advancement should depend on their own actions. It isn't a matter of criminal law, of course, but lawsuits can arise from someone being limited by such a policy. But it would also depend on the procedures used in the promotion process. (I'll say more below about this.)
Moreover, a university would find such a policy to be "unfortunate". Holding back your best associate professors is a great way to lose them. So, over time, you would expect that the quality of the faculty would decline. Only (or mostly) those associate professors with little ambition would choose to stay.
And, having everyone at full professor is also undesirable, as it makes it hard to bring in people with new ideas at the low end of the scale. Often those new faculty can revitalize a discipline locally.
But the university has a lot of levers it can pull to avoid such a stratification from happening, even by chance. If a place has "too many" full professors, then it can choose to hire fewer assistant professors and use adjuncts to control costs. It can also increase teaching loads, perhaps using subtle means like increasing class sizes.
Another solution for the too many professor problem is to offer incentives to retire. For example, a department might make an open offer to all full professors with a certain number of years of service (and perhaps an age limit) a full year's salary (or even two) if they retire now. In the US it has to be an open offer, not one made to an individual. So, a full professor over 70 with 20 years as a full professor might be offered such a buy-out.
Another "lever" at the control of administration is just to limit pay increases for everyone. This is fairly normal, in fact. It incentivizes grant writing, also. And it can increase turn-over of the faculty, but again, at the cost of the most desirable people having the most incentive to leave.
But one of the main reasons that this is unlikely to exist, or at least be common, is that the usual procedures for promotion to full professor are managed by the faculty itself, not by the administration. It isn't normally just a decision made by a dean that gets you promoted. It is on the recommendation of your peers. For promotion from assistant professor to associate it happens that the dean can veto a positive decision of the faculty for financial reasons (We'd like to keep you and you are great. We just can't afford it.). But I would find this sort of thing happening for promotion to full to be so rare as to be invisible. Hence, lawsuits.
But an additional lever comes in to play. If a university is truly in dire straits, they can disband an entire department leaving all faculty without contracts unless another department is willing to take them. This happens and is one of the ways tenured faculty might lose a job legally.
But, also note that once a person becomes an associate professor, the clock starts ticking for the administration to assure that in a few years, say ten or so, that the person will be due for promotion. So, they have adequate notice to assure that decisions are properly made so that it won't be a financial issue when it arises.