I have to ask, is it okay if I tell a friend that the gift they bought me doesn't work?
Did your friend ask about the gift? I can't believe you want to tell them that about it.
No, I just want to rub it in
You should be appreciative of the gifts you receive. Rubbing it in your friend's face that their gift does not work will make you appear ungrateful. Instead, you should figure out if the gift can be fixed.
Nah, that would be too hard since I want to show my friend it doesn't work.
If you get a gift it is always the best thing to do to just say thanks and that's all if you have any issue with it. You can always try to get it fixed and not rub anything in. Be the bigger person and do what is moral for all.