All judgments recovered against a town or against town officers, in actions prosecuted by or against them in their names of office, shall not be collected by execution, but shall be a town charge and when levied and collected shall be paid to the person or persons to whom the same shall have been adjudged.