I doubt it is illegal, but I would just sell it with a stock rom on it. Almost all roms have some sort of problem (including stock ones), and it would be easier for the buyer to get support on a stock rom. If they really want a custom ROM, it would be better for them to get it on the phone themselves
.