I'm sorry you had to go through this unfortunate experience, but I've heard that the tram/bus company is not very understanding or lenient at all toward visitors who simply make mistakes.
Did you already pay the fine?? You should have been given a notice and the notice should have info on appealing the fine.
You could have a case for asking for an appeal - was your voucher for the exact amount of the cost of a ticket?
Can you get your friend's tickets so that you can show they are all bought at the same time and that the machine made an error in issuing a voucher instead of a ticket?
If the voucher shows you were actually paying the full amount of the tram ticket, you actually put the money in and the machine made an error in not issuing a ticket. If you have the other two tickets in hand to show that they were all purchased at the same time and the money was inserted into the machine, then you could argue for machine error.
I suggest you contact the company through the contact info here:
https://www.gestramvia.it/talk-to-gest/?lang=en and request for assistance.
On board you came into contact with Autolinee Toscane personnel so I am not sure whether GEST will just send you over to them, in that case you could just also include in your request for assistance the AT company - their FAQ section has a part dedicated to "fines" and the info on there says to send an email within 30 days (this page
https://www.at-bus.it/en/talk-at/faq)
You can appeal a fine within 30 days. In case of a minor, the appeal must be submitted by a parent or a legal representative, writing to: fines@at-bus.it
The FAQ has another question on why it takes a long time, so it means it likely will take a long time to hear back and all, but I would recommend you write and write and write until you get a response. Let me know how it goes, good luck!!