The vote gave final passage to Republicans’ megabill to fund immigration enforcement through the remainder of President Trump’s term, clearing it for his signature.