If forced to perform such a task, I would have a difficult choice: dress appropriately for work as a slave and produce a level of quality consistent with involuntary servitude, swallow a bottle of ipecac at the start of the ceremony and go home for medical reasons after it took effect, or go to prison rather than pay a fine over an evil and unconstitutional demand from a court that lost its presumption of legitimacy when it issued an illegal order.
As for avoiding such situations, I think those in service occupations have to agree to accept such contracts and only later cancel due to unforeseen conflicts. The gay mafia does not deserve the respect of honest responses to their demands - when they crossed the line into evil litigation, they forfeited the right to be treated with integrity.
I’ll state my simple and elegant solution to this sort of thing:
Take the pictures. Bake the cake. Do it to your usual standards (this avoiding further lawsuits)
By state clearly and upfront that all profits from the work will be donated to a Christian organization that offers gay conversion therapy.
And watch as the legal threat to your business suddenly vanishes.