"Illegal" means contrary to the law. Plenty of things that are illegal but carry no criminal penalties.
As a practical matter, the court would rule that sham candidates are impermissible, and then their opponents would have an opportunity to remove them from the ballot via a civil lawsuit, or seek sanctions again whoever put them up, or collect civil damages, or in an extreme case overturn an election altogether.