Hungary’s parliament has ratified Sweden’s bid to join NATO, clearing the last major obstacle to membership.