It would not work in Maine. You have to be enrolled in the party that you are seeking the nomination for. The ballots would be thrown out/considered blank in counting.
Also in Maine a write in candidate to be declared at least 45 days before an election.
Interesting.
BoIaB, Bernie is not a registered Dem.