Electronic cigarette giant Juul Labs Inc. will pay $40 million to North Carolina and take more action to prevent underage use and sales, according to a landmark legal settlement announced on Monday after years of accusations that the company had fueled an explosion in teen vaping.