Consider speaking to the team manager directly on behalf of B. I think it is actually safer for you, and more likely to lead to a positive result for the intern, than contacting HR.
You should not say "I'm concerned that you are favoring your friend...". In fact, I wouldn't mention A at all. I would say something like:
In my experience, B has real potential and is a hard worker. I'm concerned that he just hasn't had an opportunity to succeed here. Is there any way we can give him more of a chance to show what he is capable of?
Even better if you can make it specific and volunteer to get involved:
I think he could really help out on project XYZ that I've been working on. Is there any way we could keep him here a few more months to work on that? I'd be happy to help show him the ropes.
I think you are unlikely to stop the favoritism. The team manager probably has wide latitude in how he deploys the interns, and there is unlikely to be any decisive evidence to back up claims of unfairness. But there might be a way of giving B a chance, too, and that is your best bet.
Whether this is possible depends on the details of the situation: Is the internship fixed or open ended? Are the two clearly competing for only a single position? etc.