Here is a similar post, but not with a code example, just a suggested solution:
One idea is to automatically change the slug as soon as the event has ended and the page has a different status. Adding a timestamp would be one way to avoid duplicate titles in the future.
status: listed: → yoga-workshop
status: unlisted: → archived20231211-yoga-workshop