Yes, mobile device owners can get viruses from phone chargers that have been compromised. For this reason, mobile device owners should avoid public USB charging cables and only use official cables where possible.
Phone chargers, like other IT devices, come with built-in installed firmware because of which phone chargers can form a line of communication with another device when connected. Hackers use different tools to infect such phone chargers and corrupt the firmware used to form the communication channel. Hackers then load malware into phone charger stations available to the public.