In my humble opinion, Joghurt to be treated as an uncountable mass, like Mus. If referring to a serving of joghurt or particular kinds (as for the sands), you might use an article, and der Joghurt might well derive from der Joghurt-Becher, which is quite idiomatic, and ein Becher Joghurt*, equivalent to "Ich trinke ein (Glas) Wasser", though nobody eats a "Joghurt-Becher"; likewise die Schale Joghurt or das Glas/Schälchen Joghurt, or whatever else. The plural -s carries over, but sounds just a little weird, "Ich habe 5 Muse gegessen".
Indeed, die and das Mus both exist, but only der Sand. I'd speculate that age of the word plays a role, because many transgender words (what's the correct term again?) are borrowed (apple sauce vs Apfelmus, hence unlikely Germanic; ). Given enough time, a variant might win, and for diverging senses, separate genders might proliferate.
The uncountable distinction might not work for all words, and the substitution heuristic might not be all that is too it. Euphony could play a role, if vowelharmony differs across dialects.