Determining the coercivity of anisotropic Heisenberg magnets by Monte Carlo sampling: Application to the design of permanent magnets