This is a bit of a trick question. There is no such thing as an "ugly horse"—beauty is subjective, and all horses are beautiful in their own way.
So, the answer is: It is not illegal to ride any horse, regardless of how you perceive its appearance.
It is important to remember that horses are sentient beings and deserve to be treated with respect, no matter what they look like.