If you were a woman, who wanted to be a man, could you get a penis? And once you got your penis, could you masturbate, ejaculate, and experience other male sexual behaviors?
And vice versa. If you were a man, who wanted to be a woman, could you then get your penis removed, and then masturbate?
Whether you're simply curious about the logistics of surgery or this is something you'd like to consider for yourself, props for asking this important question! There are a few different kinds of gender reassignment surgeries to highlight. Each of them has different benefits and drawbacks, the preservation of sensation being one of those areas for consideration.
Transgender people, those who feel that their assigned sex at birth is an incorrect or incomplete description of themselves, vary tremendously about whether or not they choose to seek gender reassignment surgeries, and if so, which ones they elect to undergo. In addition, intersexed persons, those born exhibiting a mixture of male and female genitals, may also consider themselves part of the transgendered community and may or may not elect to undergo hormonal and/or surgical treatments to align their external genitals to their gender identity.
A sex change requires several steps, the last of which is gender reassignment surgery (GRS). The transition process also entails psychological counseling and screening, preoperative treatment including hormone therapy, and a "testing" period (usually over one year) where the individual will live life according to her/his gender identity. Due to the permanency of this procedure, it's important that transgender people seeking surgery work closely with their health care provider and a mental health professional throughout the entire transition.
For trans women (people assigned the male gender at birth who identify as women or in a more female-oriented way), the creation of a vagina and clitoris usually preserves sensation. Formation of a vagina can be done with the use of penile tissue or a colon graft. The glans penis (the head of the penis) is used in the creation of a clitoris while the scrotum (with testes removed) is usually used in the creation of labia. Penile skin is typically inverted and then used to create a vagina. If If a colon graft is used in the formation of a vagina, the tissue is self-lubricating (though because the lubrication is present at all times, it may be bothersome). After the surgical creation of the vagina for either type of procedure, vaginal dilators are commonly used as part of the aftercare to maintain size and depth for varying lengths of time. After fully healed, most trans women can comfortably have penetrative sex with varying levels of sensation.
There are two primary forms of genital surgery for trans men (people assigned the female gender at birth who identify as men or in a more male-oriented way). One form preserves sensation while the other does not. Phalloplasty involves a hysterectomy plus the penile and silicone testicular implants. The penis is usually constructed using skin from the abdomen. It is a pretty extensive surgery done in three or four stages. At the end of it, the man may urinate standing up and can have an erection by inserting a silicone rod when desired. This form doesn't appear 100 percent "penis-like" and it does not preserve sensation.
The second type of penis reconstruction is called metoidioplasty and it does preserve sensation because it creates a penis from the clitoris. Many trans men who undergo this surgery are on androgens which enlarge the clitoris to usually four to six centimeters. In this procedure, the clitoris is shifted farther forward and the labia are sewn up, sometimes with silicone implants to create a scrotum. The urethra can be lengthened as well in this surgery. While the phallus is smaller than a typical man's penis, it can maintain an erection without the need for a prosthetic device since the clitoris is erectile tissue and contains more nerve endings than the glans penis.
For those who desire surgery and are not covered by health insurance, the out-of-pocket expense is, much like other surgeries, significant. For those who do have insurance, the cost will vary by person, depending on their plan and level of coverage.
All of these surgeries require some time for healing before masturbation and sexual activity can safely (and enjoyably) be resumed. More extensive information for transgender health, including information on gender presentation, hormones, identity documents, and much more can be found at the Center of Excellence for Transgender Health at the University of California, San Francisco.