If you don't feel sorry for them, you don't, but if you still want to try lending an ear to them, or help them, you can.
Saying things like "I'm sorry to hear, is there anything I can do to help? -offers a hug-" might help. That's what I've usually gone with over the years,
From there, if they don't say there's nothing you can help with, you could always say "well, if you do think of anything, I'm always here" and if they do say something you can help with, you can take that offer up. Even just listening to them complain may help them out a bit. Maybe they feel bad for moaning about their pain all the time, so you can assure them they are not bothering you/not ranting/welcome to rant etc. whatever the appropriate response is.
If it's a local friend, maybe offer to help them around the house, or do their grocery shopping.
I couldn't tell you how to genuinely be sympathetic or empathetic though. I have this very same problem. I just go with what is "acceptable" as a response.
_________________
Your Aspie score: 187 of 200
Your neurotypical (non-autistic) score: 25 of 200
AQ: 43
Empathy Quotient: 8
I have ASD, ADHD, Hypermobility Syndrome.