It is possible, in a way- some folks with penises practice something called "semen retention" or "injaculation" which is essentially where people practice getting themselves up to the point of orgasm and then either stopping masturbation or sex entirely, or tensing/pressing on the musculus pubococcygeus – also known as the PC muscle -- which is near the anus. Apparently, this squeezes closed a spermatic duct which means the sperm is encouraged to stay in the sperm sac rather than coming out of the body. I can't personally vouch for this as I've never tried it, but there are lots of resources on the internet if you search "semen retention" or "injaculation" that can explain it in more detail.