Hello the gemara yevamos 42 seems to go through many possibilities to be able to allow a woman to remarry without having to wait three months. Each time the gemara answers why the test to assure she is not pregnant with a child of her first husband is not conclusive and leaves it at 3 months. However at that time, they did not have things like sonograms, and pregnancy tests. It seems that if it were possible the gemara would prefer to allow a woman to remarry prior to three months, otherwise why would it go through so much time to test every possibility that might allow her. For example, the gemara would accept that she walk on soft soil and that we judge by her weight, were it not that she would possibly try to hide the pregnancy somehow. This is not a very advanced or conclusive test, and yet still the gemara’s only concern is that she might try to alter the results. That said, why would we not utilize the tests we are able to apply now in our times.
Technically an ultrasound might let us know if physically she is pregnant or not, however the gezeira of Chazal is a “lo plug” and includes all women who were married. Even if she was very young and couldn’t yet have children, very old, or even physically sterile. Therefore even if we would be able to determine that she isn’t pregnant the rule will still apply.
Rambam Hilchos Gittin 11-20, Shulchan Aruch E:H 13-1, Rema 13-6.