To behave in a way that shows that you are very sorry for something that you have done wrong – in ancient Biblical times people wore very uncomfortable sackcloth (cloth for sacks) for mourning and also to repent for something that they did wrong.
The man was asked to don sackcloth and ashes to repent for his terrible mistake.