It depends on how badly it's broken.
First of all, the hamster needs to go to the vet. A pet store is not a vet, and they're not qualified to give you medical advice.
For a simple break, the vet will typically recommend you confine your hamster to a much smaller cage, prescribe pain medication (this is vital -- would you want to limp around on a shattered leg without even an advil to help?) and possibly an antibiotic.
For a more complicated break, the leg may need to be amputated.
We are as gods to the beasts of the fields. We order the time o' their birth and the time o' their death. Between times, we ha' a duty. - Terry Pratchett.
"Men have forgotten this truth", said the fox, "But you must not forget it. You become responsible, forever, for what you have tamed. - Antoine de Saint-Exupéry