I’ve never tried it, but according to the developer documentation you can use SimulAVR to simulate a microcontroller.
https://www.klipper3d.org/Debugging.html#testing-with-simulavr