That's a tough situation. Is the school small because you are in a rural area? If not, finding something he can do outside school to boost his confidence might help - a youth drama group (they are famous for helping people with low confidence) or a martial arts group (same thing - great mind-body work on self respect and self-discipline.) Some other sports - maybe rowing or a local team, or scouts, might give him a wider option of friends. Something mixed might help if he finds girls easier to talk with and befriend.
He's old enough that you can't force this stuff on him, but you could have a straightforward chat and explain your concerns, asking him to take up one of these options for a term to see if it helps.
DS2 is quite short of friends and confidence, and I get concerned a lot. He has a group he goes to once a week. TBH he's made no friends there, but the upside is that he has become really good at what he does there, and in itself, that has given him self-confidence and motivation for his future. And it's something he loves to do in his spare time, instead of just being stuck doing computer games. Is there a hobby he might want to take up - playing an instrument or drawing graphic novels - something you can do alone but get confidence and satisfaction from? That sort of thing can lead to strong friendships later in life when you meet people who share your interests. Or he might make friends online if he joins a specific hobby-related chat room.
Help remind him that there's a vast, interesting world out there beyond school. Maybe take him on visits to some sixth form colleges, or uni open days (not too early if something sparks his interest.) He's not happy were he is and with the people around him, but that's no reason why he might not be happy somewhere else. Try and get him to see the connection between hard work for GCSEs and wider options later in life.
One benefit of not having a massive, complex social life at his age is that you can bury yourself in work. Of course it's better to have a happy balance, but if there isn't one, he can make the best of his time. (All my friends left school at 16 and I was left in 6th form with a clique that didn't include me. I put my head down and got great grades through sheer loneliness. The grades came in handy and I made friends elsewhere.)