There are some people who specifically don't want to know their baby's gender before birth.
Is there any halachic basis to this, or is it just superstition?
I know of one posek who proved that this is perfectly fine, from the fact that many seforim cite traditional segulos to determine a fetus' gender. Obviously, then, there is nothing improper about knowing the gender beforehand. (One could argue that knowing with certainty is worse, but this seems like a distinction without a difference. And besides, even sonography is far from foolproof.)
It seems that it it Muttar, though some would say it isn't ideal. R' Avraham S. Avraham writes the following (Nishmas Avraham Vol 2, p109):
.. Incidentally, is a woman permitted to undergo sonography (ultrasound) to learn what the sex of the fetus is? The Midrash (Midrash Rabah, Bereishis 65:12) enumerates seven things whichare hidden from man, one of them being the sex of the fetus.
The Yefei To'ar gives two reasons for this: This knowledge may grieve the parents throughout the pregnancy if the sex of the baby is not of their choice; if they wish for a boy and discover that this is indeed the sex of the fetus, it will diminish their joy at the birth and the mother will not have the full reward for her labor pains.
On the other hand, the Gemara (Pesachim 54b) also enumerates the seven things that are hidden from man but the sex of the fetus is not one of them.
Rav Neuwirth shlita [zatzal] told me that it woould be preferable not to undergo sonography for this purpose.