Considering what St Paul said in 1 Corinthians 8:1-13 and 10:23-33, about not eating meat offered to idols not so much for our own sake but for the sake of others, lest by following our example but with the wrong intention they commit sin, I think a Catholic could bake a cake for a gay wedding as long as in doing so he does not intend to celebrate the wedding but, since those who don’t know his intention are very likely to misperceive his action as an endorsement of gay weddings, he ought not to bake such a cake, lest others are wrongly-encouraged by his example into supporting gay weddings.