As a former lifeguard I can say that unless your son is extremely muscular his gender should make little difference in whether he can float. Girls do tend to have more body fat (once they hit puberty) so they may float a little easier, but unless he is really muscular (pretty rare for a 12 year old) that is probably not the issue. I taught swimming lessons and found fear and body tension to be the biggest deterrents. Sometimes something as simple as putting goggles on helps relax the person so they can float. Who is trying to teach him? You might want to try a different instructor.
It can be hard for anyone to learn how to float. For some people its easier than it is for others. Males usually have a bit harder time to float because of their lean mass and lower body fat. As Janet suggested, finding a different instructor might be a good idea and it can help. Also, some people like the water more than others and they become familiar with it in a much less time. Have patience and he will eventually learn how to float and swim better.
I think that this is a psychological thing. But maybe some physics help to read at https://ca.edubirdie.com/physics-help could help a little bit? I mean that you need psychologically influence on your sun and hope you could help him to swim.