Anonymity is in no way related to legality. That would be like saying a death threat isn't illegal because the person didn't sign their name at the bottom. Having said that, I've done some research into the electoral law and at this stage I can't find anywhere that states that casting an "informal vote" is illegal - I guess this is an urban myth in Australia. While researching I did however find a news article (not from a great news source, but an acceptable one) which mentioned that in our last federal election 20% of Australians either didn't show up or cast an informal vote. So even with compulsory voting, there's not necessarily a full voter turnout (if that makes sense).
I think of this episode whenever I go to the polls (singing the song in my head: "Let's get out the vote! Let's make our voices heard! We've been given the right to choose between a douche and a turd!")