I know, this would have been a different story, but when Black Zetsu impaled Madara, Madara could have used Izanagi because he still had the Sharingan, as I know he can switch.
First, Madara always believed himself to be completely invincible. When Black Zetsu stabbed him, he could not even realise that he was being betrayed; it was completely out of his expectation. And it only took a very short period of time for Zetsu to gain complete control of his body.
Second, a huge weakness of Izanagi is that, it has be activated first. It is not a reset jutsu. It only can manipulate everything that happens between its activation and Sharingan going blind
Madara could have used Izanagi, he still had the Sharingan, as I know he can switch.
Having the Sharingan alone isn't enough, you need to activate the Izanagi beforehand to perform this jutsu. If you recall from Sasuke against Danzo, Danzo had to activate the jutsu each time he had to use a new eye. That means the jutsu needs to be activated beforehand. As an example when Madara was fighting Hashirama, even then he activated Izanagi at first when Hashirama was about to kill him.