At 4yo many children will have strong preferences for having the blue bowl, the green jumper, the stripy pen, the third from left toilet cubical etc.
And they can be devastated when they don't get it. Wanting to choose a brother or sister is exactly the same thing.
The Op isn't saying that she is encouraging or thinks it's right, simply how to handle it. She's wondering if it's better to know, and let her dd know so that if she's upset then they get that over before the baby actually is here, when they might have less patience and headspace to deal with it.
And that's a perfectly good question.
My dd was born without a hand. We found out at the 20 week scan. It's about 50/50 who finds out at a scan and who finds out at birth.
It's been often discussed which is best.
Funnily enough, most people who found out at the scan say that was best, because they were able to work it through, do research, and when baby is born, just rejoice in the baby.
But most people who didn't find out until birth say they think that was best. They didn't have the long worry that there might be other issues (less than 1% do have other issues, but if they do they can be major), or have to think about it, they just have to get on with the reality.
The people who did feel the other way is better often are struggling in other ways too, and this is a easy thing to blame.
And OP, I suspect this is similar. if you choose to find out and tell now, then she'll probably be upset; but get over it and be excited about having a brother when they're born (if a boy).
If you wait, she may have a greater shock at the time, but will have to get on with the reality in front of her, so less time to think about it.
Whichever way you do, you'll probably feel that you're glad you did it that way, but if it does work out badly, it probably would have worked badly the other way, and there's more to it than just being a boy/girl.
And for what it's worth, my nearly 4yo announced when I was 8 months pregnant that "that baby is not using my buggy!"
Bearing in mind that she'd spent nearly 4 years kicking up a stink if I ever tried to put her in/ask her to go in the buggy, this did feel a little unfair.
However when baby arrived, baby went in the buggy and I heard nothing about it being her buggy or that the baby wasn't to use it.
4yos are like that.