Well done, OP. You are considerably calmer and more rationale than I would be.
I can't see that any "contract" would be enforceable - your son is a minor and, even if he were in a position to do so, then I think there is a massive inequality in bargaining power, and duress, so it is clearly, legally, a nonsense. That said, it seems like the school's attempt to get him to buy into their BS crazy blue sky notions of social normality.
In my experience, when confronted with a bullying issues, schools go one of two ways - restorative justice or zero tolerance. Current HT seems to have plumbed for the former, in a particularly crude, ill informed, way.
The reality is you can't force friendships, only encourage them, or provide a nurturing environment - none of which is aided by forcing a quiet sensitive child to spend time with someone they don't like, and who is, or may be perceived, as a threat. It's just plain dumb, and in my experience, is likely to make life for the quite person harder, if not insufferable. (I hesitate to use the word "victim" - but you get my drift).
Explain your concerns to the head, governors (who are meant to be a critical friend to the HT, although I accept not all) and local authority, if necessary (in my experience, a lot of them can be sensible and very helpful, although not all). Stick to your guns, be reasonable, and record everything.
By the way, obviously don't know your son, but being quiet and preferring books etc. doesn't mean that he has any condition - other than possibly mild introversion (which half the population has). It is perfectly normal not to want to socialise with certain people - especially if they are bullies or there is a plain personality clash. From what you say, it isn't affecting their schooling - so total overreaction on HT's part. Choosing not to play is a perfectly valid and mature approach!