Different schools do it differently. For example mine went through all the subject awards and dux before atars were released, I think even before exams happened (it may have been the evening of muck up day). As a result our dux is given for who the teachers think will do their best in exams/perfomances in sacs. Normally our school only gives one, but in our year they gave three, as they couldn't split the three of us. In the end atar wise, the three of us ended up with the 1st, 2nd and 4th highest atar scores for our school (there were 2 people who got the same for 2nd, one of which wasn't given the dux award). Normally, for our school at least, who they pick for dux normally ends up with the highest score, since they can tell who will most likely do well. I was the one who got the 4th highest and the dux, to be honest I think the teachers were expecting me to do better for my English study score.
tl;dr, it depends on how your school does it, but a lot base it on what atar you actually get.