Israel’s top military prosecutor has resigned after admitting to leaking a video showing soldiers assaulting a Palestinian detainee.