Can you sue a transportation company that issued you an invalid ticket from a broken machine?

This is what small claims court is for. You should be able to recover the cost of your ticket + the cost of filing the papers in court. If you think you are going to get rich for "pain and suffering" I don't think that's going to happen.