If the lump is on the scrotum, it's probably not due to constipation. A protrusion from the rectum could be caused by constipation.
Testicular cancer in hamsters is not uncommon, so if it's on the testicle, there's a good chance that's what it is. Neutering is the cure.
If the lump is not actually on the testicle, check to see if it's hard or if it's soft and feels like it may have fluid in it. A hard lump is likely to be tumor.It could be benign or cancerous. Since it's near the body surface, a vet can remove it.
If the lump is soft and seems to be liquid-filled, it's more likely to be an abscess. Your vet can lance it, and then treat your hamster with antibiotics. Don't try to lance it yourself, as it's easy to drive infection further into the body. Here's a site where you can read about the different types of lumps (you'll need to scroll down):
I hope you're able to get your little pet treated soon and that he'll recover quickly. If you have further questions about this, just let me know by clicking on REPLY.
(If you find my answer helpful, please click on ACCEPT. Thank you.)