What you're describing is entirely normal social development for that stage, and exactly the same thing happened (and still happens, to a lesser extent) to my children, particularly my younger child (who cared/cares more about what people think about him than my older child). He's in an environment where he has different preferences to his friends, and both he and they are not yet learned enough to handle this.
See for example this article on social development in preschoolers:
At age three, your child will be much less selfish than she was at two. She’ll also be less dependent on you, a sign that her own sense of identity is stronger and more secure. Now she’ll actually play with other children, interacting instead of just playing side by side. In the process, she’ll recognize that not everyone thinks exactly as she does and that each of her playmates has many unique qualities, some attractive and some not. You’ll also find her drifting toward certain children and starting to develop friendships with them. As she creates these friendships, she’ll discover that she, too, has special qualities that make her likable—a revelation that will give a vital boost to her self-esteem.
That's the phase he's in right now - learning to recognize those differences, and identifying the children that he shares common interests with. It's a difficult thing (heck, it's difficult for me now), and he (and all of his classmates) will need to work out things for themselves to some extent.
What you can do is to help it along a bit by talking about it, by giving him tools to work with, and by giving him as many opportunities as you can to work on those friendships.
- Talk about it: let him express his feelings, in a comfortable environment. Give him examples of your own life that are relevant. Help him understand that this isn't a problem - that it's just part of normal development - but also that you're there to help him figure things out. Don't push him to talk when he doesn't want to, but when he does want to, let him! Help him understand the action-consequence relationship - i.e., he did X so Y happened; don't make him feel like it's his fault that Y happened, it's not his fault that people made fun of him, but at the same time he should understand that they're connected.
- Give him tools: When he does tell you about the problems, make specific, actionable suggestions for how to deal with the kind of issues he's having. Again, give examples of what you have done in your life. As an example, if he's complaining that nobody will play with him, perhaps role-play introducing himself to a new friend. If he's complaining that people make fun of him when he does something, give him the tools both to process that (understand that the kids are being silly) and to deal with it (if it's minor, then make a joke back or play into it; if it's major, then talk to a teacher).
- Give him opportunities to work on it: Try to identify potential playmates, and schedule playdates with them. Ask the teacher who he gravitates towards. It's possible that some of the kids that won't play with him in school could still be willing to play outside of school in a 1-on-1 environment; maybe they're feeling the social pressures also to conform! Also, don't limit this to boys, unless it's just impossible in your culture/area; it may be that his ideal playmate is a girl, at this stage in his development (or any!). My younger son bounces around - some months he plays with the girls, then a month later he plays with the boys in his class. He's very imaginative and creative, and doesn't always feel like the rough and tumble play the boys prefer; sometimes he wants to play house.
Ultimately, the point here is to help him find ways to deal with it on his own as much as possible - he'll work through this, and he'll be better equipped later in life for socialization once he does. Don't be tempted to intervene or to ask the school to, unless this is at the level of bullying. Do ask the school to tell you how he's doing, though, and ask them to give you ideas for how to help him outside of school - they've probably worked with dozens of other kids with similar problems, and can give you ideas for what work with him.