I remember than on older MacBooks, it was possible to charge any USB device with the lid closed and without connecting to a power outlet.
However, at some point this has been disabled. I am currently using MacBook Pro (Retina, 13-inch, Early 2015) with macOS High Sierra (10.3.6) and this option is not available by default.
Is it possible to change this default setting and bring back the old behaviour?