How to make iPhone charge over USB cable when locked?
Fixed.

Go into the security settings (Settings -> Touch ID and Passcode), and enable the "USB Accessories" switch (it should be green with the virtual switch-button to the right). This enables charging off any connection while locked.

Unfortunately this also disables the privacy/security feature that thwarts hacktools with physical access, so if you enable the USB Accessories option you will want to take extra precautions to prevent unauthorized physical device access and refrain from plugging into dodgy machines.