From a legal standpoint, putting a suitable disclaimer stating that the views do not represent the company may be sufficient to keep the company away from consequences. However, that depends on local laws and often also on what exactly was said, and can best be answered by a local lawyer.
The general public, though, may not care about such disclaimers. People rarely compartmentalize things like those based on logical rules. In fact, it is nowadays more common for controversial statements to be dragged out of context to suit one's personal agenda or to score political points.
If the CEO of Acme Corporation says, "I absolutely hate X group. All X group people should just die in hell. Of course, this is my personal opinion, Acme Corporation is always delighted to serve X group people.", I cannot imagine group X people thinking, "Oh right, that's just his personal opinion, so no problem, let's buy a lot more stuff from Acme to delight him."