About procedures in use on male inmates in asylums I found interesting the Joseph W. Howe "Excessive Venery Masturbation and Continence (1889) book.
He describes several clinical cases.
"years ago I had an epileptic masturbator under treatment in Charity Hospital. He foiled every attempt made to prevent him from masturbating. The penis and scrotum were blistered, so that
he could not touch them, but he still managed to complete the act by rubbing the perineum with his fingers. His hands were tied behind his back, but this also was unsuccessful, for the
next day he was seen to slide down to the foot of the bed, and rub his perineum against the foot piece. He was finally tied hand and foot to the bed
so that he could not move a muscle."
In many cases the treatment was ablation of the prepuce
"I was uncertain to what cause to attribute these pollutions, when, on examining the genital organs, I noticed that the opening of the prepuce was very narrow, and that abundance of sebaceous
matter escaped. [...] I concluded, therefore,
that the natural phimosis, by preventing the discharge of the sebaceous secretion, was the cause of involuntary discharges, and in consequence recommended circumcision, which was performed immmediately. [...]
The glans itself was vividly red, almost entirely deprived of its epithelium, extremely sensitive— the least friction causing a discharge of blood.
From this moment he passed a fortnight at a time, and some times longer without having nocturnal pollutions"
He continues with necessity of circumcision in masturbators
"Circumcision will be necessary when there is hyperasthesia of the head of the penis from the
irritation of retained sebaceous matter consequent upon elongation and contraction of the prepuce."
And further exotic treatments such as
Introduction of medicated bougies, Steel sounds,
Acupuncture, Application of electric rings,
Spermatorrha rings, Rectal pessaries, leeches.
"When the parts are morbidly sensitive leeches may be applied to the perineum, and use made, twice daily, of some astringent and anodyne injection"
"The use of the steel sound and electricity helps to give tone to the parts. The use of local astringents to the prostatic sinus' is often of marked advantage."
"I have used with advantage urethral suppositories of butter of codos containing one-quarter of a grain of carbolic acid pushed down to the prostatic urethra by a steel sound and allowed to
dissolve there."
"The urethral electrode well oiled and warmed is slowly introduced through the urethral canal to the
neck of the bladder, while the sponge covered electrode is placed over the genito-Spinal center at the junction of the dorsal with the lumbar vertebra, and moved up and down over the vertebral column as far as the tip of the coccyx. While the sponge is being moved over these parts the urethral electrode is Slowly withdrawn until its point reaches the bulbous portion of the urethra."
"Puncturing the integument over the spermatic cord with needles is sometimes beneficial. It may be advisable, in very bad cases, to rub into the punctures a mixture of equal parts of croton Oil and olive Oil"
"Needles from two to three inches in length are passed through the perineum into the prostate gland and neck of the bladder.
[...] The first needle is introduced in the median line midway between the anus and scrotum. The second is inserted into the prostate half an inch
below the first, and the third needle is introduced half an inch above the first one. They are kept in position half or three quarters of an hour. [...]
Some surgeons recommend the introduction of needles into the testicles and spermatic cord for the same purpose. "
For patients not responding to therapies
"It may be well to exercise strict supervision over the patient, and use the baths, tonics and electricity for a few weeks, and then if there is no good result, the patient should be castrated without delay, and the penis, pubes and perineum covered with canthara collodion. Simple castration will not at once stop ejaculations through the urethral canal, so it is consequently necessary to place the parts in such a condition as to prevent them from being handled. If these measures fail, I see no objection to removing the whole of the external genital apparatus."
So there is a plethora of forced treatments including male genitals modifications described with so much details.
Reading Dr. Howe descriptions I cannot avoid to think how would be being one of his patients.