Yes a broken toe can sometimes get infected.
Most broken toes however heal pretty good even without medical treatment but if you do have a broken toe it's best to go the doctor or urgent care center to have the broken toe fixed.
If you leave the broken toe untreated then there's a possibility of infection.
So to be safe see a doctor or go to urgent care or emergency room just to be safe and prevent further issues and possible infections from the broken toe.
Most broken toes usually heal within 4 weeks to 6 weeks but if it doesn't heal within 6 weeks then you should see a doctor about it.
If you think the broken toe is becoming infected or the toe is swelling, increases in pain etc then see a doctor about it.