Nothing prevents enrolling. Question is, what good will it do if you win if you are out of status?
If still in valid nonimmigrant status, there is no problem here. But once you have fallen out of status (unless for a very brief time at this point - speak with a lawyer to see if there is a solution for this), there would be no way for you to Adjust Status in the U.,S. based on the DV lottery visa were you to win. Going abroad to process, once you have accrued unlawful presence, subjects you to a three year bar to reentry after 180 days' unlawful presence and a ten-year bar after a years' unlawful presence. Waivers are available, but difficult to get.
Speak with a lawyer to be sure, but chances are that someone out of status for more than six months will see no benefit from entering the lottery even if they win.