There is no back-tracking rule within a region - For example you could fly YUL-YVR-EWR-LAS-SJU.
Yes, you can transit twice through the same city.
Another option from HKG to SYD would be via BR ( transit in TPE - permitted even after your stop there).
Best way to validate your itinerary is to plug it into the Star-Alliance web site.