What if it was the HOA. You belong to an HOA it comes out that you said some particularly nasty things about a gay neighbor. Does the HOA have the rights to fine you. Force you to sell your house if 75% of the members vote you out.
If you signed a contract to that effect or bought a place with a deed covenant of that type, the answer might be “yes.” In the sense that it’s legal, not that it’s necessarily right or moral.
If you buy a place with an HOA, you need to read AND UNDERSTAND the by-laws very well before signing in the dotted line.