Dijkstra tracks the best cost to reach each position. In a normal graph, position is the entire state. Here, position alone is not enough. Why?
Because arriving at city 5 with 0 stops left is different from arriving at city 5 with 3 stops left. The first state is a dead end. The second can still explore neighbors. Your state is a pair: (city, stops_remaining). You track the best cost to reach each (city, k) pair. That's how you handle the constraint.