I recently lost my daughter at 21 weeks, and my best friend is expecting - she is six weeks behind where I was.
We live a fair distance from each other, but we were very open throughout our pregnancies as you can imagine, on the phone all the time, and she was incredible when we were going through everything.
She had her 20 week scan a few weeks ago, I knew when it was but she very tactfully didn't mention, or discuss it. I asked her about it, and turns out she's having a girl.
Whilst it hurt, really hurt, the overwhelming feeling was honestly that I am delighted for her. She and her lovely husband have a beautiful son, and they were hoping for a daughter.
My grief won't fade, but sharing her joy is helping a bit. That said, I haven't planned to see her whilst she's pregnant, and possibly won't meet her little girl for a while. Her son was 5 weeks early, so there's every possibility her little one may arrive close to my due date. She understands these feelings and is fully supportive.
Whilst everyone is different, and you know your friend best, if it were me I'd want to know. Be tactful, tell her over the phone so she doesn't have to keep face if she wants to break down (I did after hearing the gender) and let her ask questions, rather than volunteering information.