Charging an iPhone from a closed MacBook
You would want to enable closed clamshell mode (search Apple.com/support) for the details on what is required on which models:


Attached external display
Connected USB device like keyboard or mouse 
Connected to power charger and not running on battery


At this point, you'll get the normal USB charging or the enhanced charge if the hardware detects your iOS device as benefitting from the capabilities of the hardware to charge at a higher rate than 500mA.

If you cannot run in closed clamshell mode, set the sleep to be long enough to get a charge and prevent the lid from closing completely. Setting up power nap will also allow brief moments of charge, but that isn't intended to get a realistic charge over USB.