North Korea and China pledged to deepen ties and resist hegemonism during foreign ministers’ talks in Beijing, amid tensions with the United States.