Using USB ports for charging when MacBook Pro is not connected to power source and with lid closed 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?
You'll need to keep your MacBook Pro awake while the lid is closed. There is no setting within macOS that lets you override the default behaviour (enter sleep mode when the lid is closed).

You can use a free 3rd party app called InsomniaX. It lets you disable the sleep mode while the lid is closed.


  It always has been a missing feature: disabling the sleep mode on a Apple Laptop. Who does not want to use it as a big juke-box or go warwalking. The best looking server ever, especially at about one inch height. This small utility is what you will want, this small utility acts as a wrapper to the Insomnia kernel extension.
  
  


Image source: http://semaja2.net/ye-ol-projects/insomniaxinfo/