I believe it is within the Beit Din's power.
In Shemos 12:22 it states “And you shall not leave the opening of your homes until morning…
Rava during times of wrath [Rashi=plague] would close his windows.” In Hilchos Shemiras Haguf Vehanefesh Halacha 13 it states, “When there is a plague in the city, one should not walk in the middle of the road being that the angel of death walks down the middle of the road, as he now has permission to pass One is to escape from a city when the plague first begins, although if one did not escape when it began then he should not run away towards its end."
In the Zohar Rav Avraham Azulaiy says the Zohar implies the best way to avoid a plague is to seclude themselves in their room and study Torah: Chesed Leavraham Mayan Chamishi Eiyn Mishpat Nehar 28.
A more recent example is when Rebbe Akiva Eiger did not allow many people in Shul during Rosh Hashanah in a Cholera outbreak.
I am no Talmid Chacham but this is what I found from research online, majority of which was from an article by Rabbi Yaakov Goldstein.