How would you acquire evidence that it is a ghost job, and they didn't just decide to hire someone else? How would you even know if there is a case worth pursuing?
We already do this for discrimination lawsuits. It turns out that you can, indeed, just do things. It's illegal to discriminate on the basis of race, and it can indeed be enforced against employers who do so to the point that employers are very, very careful now to make sure they don't do this.