Consider the child's refusal to share his belongings with others as normal behavior as it is.
He begins to learn at this age the feeling of empathy, that is, how the other can feel from a certain action, but it will be difficult to resist his impulse.
Most children up to the age of 4 put their needs first and get upset when someone takes away the things they want. Instead of being upset by these behaviors of the child, you should understand that this is a stage towards maturity.
How to teach the child to share things with others?
Turn it into entertainment. Make games by sharing toys with each other, for example a formative game. Don't compete but help the other to solve it.
Do not punish the child if he will not share things with someone else. Although you may feel embarrassed when he doesn't give a friend a toy, the only thing you will do if you reinforce or make him feel selfish is the wrong perception of sharing things. The moment the child feels uncomfortable, it will be difficult for him to learn a skill, and on the other hand, you have to accept that he will never want to share a toy. As he grows he will understand how group fun works.
Do not let the situation overheat. Remove the child from playing with his friends before the crying fits begin. Explain that the other child doesn't want him to play with his toy anymore, so he has to find another one.
Reassure your child that sharing toys does not mean the other child will get them.
Respect your child's obsessions. He may hold a toy or piece of clothing sacred, and you absolutely must not force him to share it with anyone else.
Set a good example. You share the ice cream with him, ask him if you can try on what you look like in his new hat. So he should learn from you the concept of separation.