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.
Newer iOS and hardware have a way to relax the security and allow charging / negotiation of fast charge even while locked. I'll let the OP answer cover that detail and keep the older details here.
- https://apple.stackexchange.com/a/351469/5472
The iPhone will charge at lower rates from a pure charging port, so you just want to put a data blocker on the USB so that the phone won't reject a computer and see a charge only device.
- https://www.amazon.com/PortaPow-3rd-Data-Blocker-Pack/dp/B00T0DW3F8
There are many of these and you generally get what you pay for in low cost USB accessories. I'd expect to pay $10 for either one good blocker or a pair in the US. I know you didn't want to buy hardware, but unless you can get your computer to stop signaling it's a USB data connection, iOS is going to shut down the port since that's "what it do".