I assume you are talking about a publicly traded company listed on a major stock exchange and the buyer resides in the US. (Private companies and non-US locations can change the rules really a lot.)
The short answer is no, because the company does not own the stock, various investors do. Each investor has to make an individual decision to sell or not sell. But there are complications. If an entity buys more than about 10% of the company they have to file a declaration with the SEC. The limit can be higher if they file an assertion that they are buying it solely for investment and are not seeking control of the company. If they are seeking control of the company then more paperwork must be filed and if they want to buy the whole company they may be required to make a tender offer where they offer to buy any and all shares at a specific price. If the company being bought is a financial institution, then the buyer may have to declare as a bank holding company and more regulations apply. The company can advise shareholders not to take the tender offer, but they cannot forbid it.
So the short answer is, below 10% and for investment purposes only, it is cash and carry: Whoever has the cash gets to carry the stock away. Above that various regulations and declarations apply, but the company still does not have the power prevent the purchase in most circumstances.