This is one of, what I'd surmise, many sources:
there is no written source in Jewish law that expressly forbids it.
This is an interesting example of a tradition that When you are
creating life, it is better to avoid contact with death women took
upon themselves without being told. And this tradition is carefully
guarded and well known, even more than some outright laws. You will
see why.
Jewish mothers have known for thousands of years what modern research
is only recently discovering. The unborn child is affected by the
spiritual and emotional state of the mother. Her moods, her attitudes,
and her surroundings are imprinted on the body and soul of the child.
This is why the cemetery is not the right place for a pregnant woman.
When you are creating life, it is better to avoid contact with death.
The morbid and deathly energy of a cemetery is starkly in contrast to
the process taking place inside a pregnant woman. Her focus should
remain on the beginning of life, not the end.
Furthermore, feelings of excessive grief or distress may disturb the
otherwise peaceful time in the womb. Sometimes emotional pain is
unavoidable in life, but we don't have to seek it out. An expecting
mother may be fragile and delicate at the best of times. Attending a
funeral or consecration may cause an exaggerated reaction that could
have been avoided.