The number of foreign workers in Japan reached a new high, underscoring the country’s growing reliance on people from overseas to address its chronic labor shortage.