You can try telling them what you told us. Not the whole story, like why you can't sympathize with them unless you trust them enough to understand. But you can tell them that you just don't know how to react.
People have different sensitivities to, and reactions in, social situations, and a lot of them are bad at dealing with sad news or giving advice. They might also feel uneasy talking about certain subjects. If you're feeling uneasy on the spot, you can say "sorry, I wish I could help but I don't know what to say" or something along those lines. It's an honest answer but it doesn't mean you don't care. You also can hug it out, sit there in silence with your friend, or offer to do a fun activity to help take their mind off what happened afterwards. The gesture alone is appreciated.
If it's about having to act cheerful and happy for a friend sharing good news, think about the person. They're your friend so you probably like them for some reason. Even if you can't get yourself to care about what happened, this person is someone close to you. You would like to feel happy if you could, right? You can think of it as a good thing that someone you like is happy, in a "hey, it's great that someone I like doesn't have to feel the way I do." Just don't let that thought become a negative thing for you. Otherwise, it's all about honing the acting skills. I'm sorry that things are getting harder.