By federal law, they cannot prevent consumers from joining class actions. However, they can in some states.
Also, there's a difference between an illegal contract (which is a nullity and for which no remedies are available in case of a breach) and an unenforceable contract (which may still be enforceable under theories of unjust enrichment, promissory estoppel, etc). A contract to do something illegal is an illegal contract. A contract with unconscionable (per se unfair) terms is usually an unenforceable contract.