A federal judge slashed attorneys’ fees in a $115 million data breach case settlement between Anthem Inc. and its customers.

The Aug. 16 ruling by Judge Lucy Koh of the U.S. District Court for the Northern District of California closes the long-running lawsuit against Anthem. The case stemmed from a 2015 breach that exposed Social Security numbers, birth dates, and health-care data of 78.8 million customers.

Attorneys for the class action plaintiffs are entitled to $31 million in fees, $2...