Consulting firm McKinsey & Company will pay Massachusetts $13 million as part of a settlement with dozens of states and territories over its role in the opioid epidemic.