As long as the driver does it safely, it's not a penalty to reverse back on to the track. Apparently F1 was didn't think it was unsafe (they were monitoring Hamilton's radio and listening to the instructions being given to him about it being safe to reverse).
I think the race had gone red flag just a few moments after he went off anyway (for the Bottas crash).