That can be at least somewhat deterred by registering the car with the manufacturer to get an unlock code, similar to what HTC does nowadays if you want to root one of its phones. Thus, there's a record of you having installed custom firmware (with the relevant warranty-voiding and such). While it won't
specifically detect whether or not mileage reporting has been tampered with, it
does signal to a buyer that the software is or was non-stock, and therefore all bets are off, caveat emptor, etc.
Alternately, the odometer could (and I'd argue should) be implemented in hardware, possibly as an ASIC (or maybe FPGA) plus dedicated EEPROM to store the counter, wired directly to the relevant sensors. Perhaps some data interface with the main computer, but it should be read-only. That would solve this issue right quick.