WASHINGTON—The U.S. Supreme Court on Monday in a 5-4 split said “closely held” companies can on religious grounds opt out of a federal health-care law requirement that companies provide contraception coverage to employees, carving another piece from President Barack Obama’s signature domestic achievement.

In a ruling by Justice Samuel Alito, the court’s five conservative justices wrote that private companies, such as Hobby…