Noether's second theorem in a general setting: reducible gauge theories