Can they test someone's gender through a urine test?

Yes. Any cells (including ones found in urine) can be dna- tested for a number of things, including sex.
Yes. Yes, there are tests on urine to try to determine an unborn baby's gender, but the accuracy is uncertain. The tests may be looking for traces of male dna (y chromosome) in the pregnant woman's urine. That means enough of an unborn boy's dna would have to cross the placenta, enter his mother's bloodstream, and get filtered through her kidneys into her urine ... To cause a "boy baby" test result.