Index and first Betti number of f-minimal hypersurfaces: general ambients