It sounds to me as if writing has become a major 'issue' for your son, if he won't write his name on a bag with the other children.
Although I can see that he created a situation with a natural consequence, I think I"d take a different approach and ignore the behaviour, and completely play it down. I think I'd have just written his name, whilst chatting to another adult about something else, so that it wasn't an issue.
If he senses that writing is a big deal to you, he is likely to want to do it less. If it is inconsequential, he will see the need to write and not get attention for either doing it or not. My instinct is that his 'issue' is with the 'neatness' aspect of writing, in which case I'd also ignore the neatness for a while until he gets writing through self-motivation. While he thinks there is big attention surrounding putting pencil to paper (or bag!) he will probably continue to refuse to do it. He must also have felt the attention, one way or another, from not having the bag at the end of the party, which would have an emotional impact of some sort - either anger, frustration, or pleasure that he'd somehow 'won' the day by being different.
Although he's clearly very smart to know that one person doesn't need to write his name on! Or alternatively, he could have thought, "I'll put my bag in this place here, then I'll know it's mine" or "I'll mark the corner" or "I'll tear the edge", all of whcih would be intelligent solutions. I think I'd have tended to focus on the positive problem solving aspect rather than the fact that he didnt follow the general strategy - although I know what hard work such alternative thinkers can be!
Without knowing the child, it's hard to advise, but I always found that alternative thinking can get you around a problem when meeting it head on can get you further into repeated behaviours. Just an alternative suggestion!