The current owners of a privately held company can decide who to sell the business to. (For example, a startup can choose which VC firms to raise from.) But what about a publicly-traded company? Can it prevent current shareholders from selling their shares to certain activist investors? Or rather than preventing stock sales, could it make binding requirements on its shareholders to not rock the boat? Company management and/or a majority of shareholders may not want to co-own a company with Carl Icahn, and certainly oil companies would tend to prefer to keep out environmentally activist investors.
In the U.S., being a publicly held company means that, at least, some of the shares are registered with the SEC. Without that registration most would not consider the company as public.
Registered stock is a security that has been listed in a registration statement filed with and declared effective by the Securities and Exchange Commission (SEC). The SEC requires securities to be registered or meet an exemption to registration before it is sold on the open market.
Within a class of stock, registered shares are fungible and can be sold freely on a pulbic market or between people.
A publicly held company may vary well have issued some restricted shares that have contractual, or other, constraints. Those may not be sold to the public without being registered, lifting the constraints.
So, no, in the U.S., a publicly held company, as the term is commonly used, may not have the kind of restrictions you have asked about on shares held by the public.
A public company can have shares with restrictions but it must have unrestricted registered shares to be considered public.
Limitations on transfer of shares are not defined in law
It is common, but not universal, to allow directors to refuse to register share transfers in the Rules governing a proprietary (private) company. It is uncommon, but not unknown, for such Rules to exist in a public company.
Share transfers can also be governed by third-party contracts such as shareholder deeds which generally take precedence over the company’s Rules.
So, to answer your headline question: yes.