Cities and towns like Marblehead that remain out of compliance face loss of state funding and potential state legal action.