There are 3 ways the odometer works depending on the car.
I have never seen, but did read, of a car where the speedometer was driven off a cable attached to the left front tire (not powered)... Popular Mechanics. back in the late 1960's A story series they published called Gus Wilson's Model Garage.. now as I said I have never seen this.
Most cars and trucks it is driven off the transmission output shaft. Older cars it's a cable drive, which means it's all gears and cables, and if the shaft is turning it's counting the miles.
modern cars it's an electronic linkage and if the ignition is off, it's not working.