It is usually visible around 18-22 weeks on an u/s (if baby is co-operative).
But the actual scientific bit - is that the sex is decided by the sperm that fertilises it.
All eggs have x chromosomes, sperm have x or y chromosomes.
If you get a x sperm you get a girl, if you get a y sperm you get a boy.
Two y chromosomes are not possible.
This is why we do not need men technically. It is exceptionally unethical but is possible albeit illegal and you wouldn't find any doctor who would do it.
But you can make a human embyro by stripping the nucleus of an egg (as they do to sperm for ivf) and implanting it into the nucleus of another egg. You would get a girl everytime.
This can not be done for two men by using 2 sperm as sperm do not have the neccessary information on how to make the cells divide and grow.