When you enrolled you entered a contract with the university. In that contract you promised to do certain things (like follow their code of conduct) and they promised to do certain things (like give you a transcript).
The contract probably says what the consequences are if you don't do what you promised - it may mean that they can withhold your transcript. If that is what you both contracted to do then the law will uphold it unless what was promised is illegal. In general the law doesn't care if what you promised to do is objectively fair or reasonable - you promised to do it: the law won't second guess why you made that promise.
The contract is probably subject to consumer protection law that addresses some of the imbalance in the bargaining positions between you (a student) and them (a university). This may make certain provisions unenforceable or add terms to a contract. However, at common law, a term is only unenforceable if it is "unconscionable" - basically so unfair no reasonable person would agree to it.