BRST symmetry for finite-dimensional invariances: Applications to global zero modes in string theory