The US ambassador to China will step down early next month, ending a three-year tenure marked by a trade war and increasingly bitter relations between the world’s two largest economies.