Courtrooms provide the context for great drama because of the high stakes.
Star Trek is no exception at taking advantage.
This is a community wiki answer. Add at will:
- TOS: 'The Menagerie' - Spock is the subject of a court-martial
- TOS: 'Court Martial' - Kirk is put on trial for the manslaughter of Ben Finney
- TOS: 'Amok Time' - Spock, in extremis from the 7-year Vulcan biological imperative, is taken back to Vulcan and pressed into legal one-sided divorce proceedings involving combat initiated by his wife, T'Pring; shocking surprise at T'Pring's selection of champion follows.
- TNG: 'Measure of a Man' - Data is involved in a legal case determining his legal rights under Federation law
- TNG: 'The Drumhead' - several courts-martial in an attempt to uncover a conspiracy
- DS9: 'Rules of Engagement' - Worf is charged with war crimes for destruction of an unarmed civilian vessel
- VOY: 'Author, Author' - the Doctor's rights following the unauthorised publishing of his holonovel are discussed with a legal case involved
VOY: 'Ex Post Facto' - Tom Paris is convicted of murder and has to witness the event from the victim's perspective every 14 hours.