“Couldn't you have given the ticket to a friend?” — talking about the past that didn't happen.
In the joke, the first man can't believe it: “Couldn't you have given the ticket to a friend?” To talk about the past that didn't happen, English uses a modal + have + past participle.
should have + past participle
A criticism or a regret: it was the right thing to do (or what was planned)… but it didn't happen. = aurait dû
could have + past participle
A possibility that wasn't used: it was possible… but nobody did it. In a question, it's a suggestion or a reproach. = aurait pu
would have + past participle
An imaginary result: what would have happened in a different situation. = aurait (fait)
modal + have (never has, never had) + past participle — for all the persons: I / you / he / they
should have gone. Negative: shouldn't have, couldn't have, wouldn't have.