A Massachusetts hospital system and a pair of former workers told a federal judge they had reached a deal to end a proposed class action accusing the not-for-profit of saddling their retirement plan with excessive fees that cost participants millions.