It may be illegal in your area. The hermit crab may die if you bring it home. It needs real sun, saltwater, freshwater, calcium, shelter, other crabs, sand and food.
Yes, hermit crabs will adapt to living in an man-made environment much better than most wild mammals. Simply provide them with an aquarium that contains sand, salt water, occasional sunlight, and food. They also enjoy having a variety of shells they could inhabit.