A political party is free to change the rules for nominating candidates however and whenever it chooses. It is free to nullify the decision of those voting in a particular primary. A political party is free to nominate whomever it chooses [and almost certainly multiple candidates for the same office it wishes should it choose].
Ultimately the party, not a judge, chooses whose vote matters and whose doesn't. Placing the imprimatur of the state upon a political party's process doesn't change that or make the process of candidate nomination little 'd' democratic. The people within a political party charged with making the rules for candidate selection are not elected or selected little 'd' democratically. The process of nominating candidates is not little 'd' democratic in any meaningful sense.
Whenever people talk about alternative voting systems, the consensus seems to be that it would be impossible to implement in the US. But why? What drives this obsession with choosing between two evils rather than choosing among several, where one's own views might stand a better chance?
But with regard to your question, the obvious explanation is that the voting method itself acts as a game theory attractor for a certain number of "viable" candidates, until a Nash equilibrium is reached. First-past-the-post thus eventually results in an entrenched two-party system.
This alone is ample reason for those two parties to resist any change to the voting method. Anything else might undermine their duopoly.
In some states (like California) write-in candidates also have to register and qualify, and writing in a non-qualified write-in candidate is for all purposes (except the workload for vote counters) identical to blank ballot -- even if through some fluke of coordinate protest they received a majority of cast ballots, it would just show up in the counts as a very low number of valid ballots cast.