Would this "reboot on ping failure" technique work with DietPi?

Question is why this would be needed? Some more background information could be helpful to understood the use case.

Maybe something interesting for you. A similar case Watchdog for Dietpi (Auto reboot if Internet is down)