You can, just make sure the compatability with your other livestock is perfectly fine.
Avoiding stuff like most wrasses, coral banded shrimp, arrow crabs, sally light foot crabs, large hermits, and big predatory fish is what I'm refering to.. as well as other generally aggressive cohabitants.
I've witnessed mine "fight" with an emerald crab, where the shrimp went after and literally chased down the crab, pushing it in another cave. It was very shocking and surprising how aggressive the frail looking shrimp got, after seeing that my confidence for them holding their own is boosted significantly.
Other than compatability, just be sure to have a back up plan when you run out of stars, whether it's rehoming the shrimp or feeding it afterward.