It is legal and freedom of speech does not apply: freedome of speech or the 1st Amendment only applies against the government (i.e. the government cannot limit speech) but does not apply to private businesses. A private business and its customers can contract that the customer shall not disparage (leave bad reivews or posts or "bad mouth") the business, and if you signed a contract with such a clause, it is enforceable against you.