If part of a penalty or forfeiture is payable to a town, corporation or board of public officers, they shall have the same rights in relation to such action and penalty as the county has in the cases aforesaid.