How to keep MacBook awake with lid closed + extended display?
Requirements for closed-display mode from, Use your Mac notebook computer in closed-display mode with an external display:


  To use closed-display mode with your Mac notebook, you need:  
  
  
  An AC power adapter 
  An external keyboard and mouse or trackpad, either USB or wireless  
  A USB-C to USB adapter if you're using a USB mouse or keyboard with MacBook (Retina, 12-inch, Early 2015) and later or MacBook Pro models introduced in late 2016
  An external display or projector
  
  
  If you're using a USB keyboard and mouse
  
  
  Make sure that your Mac notebook is plugged in to an outlet using the AC power adapter.
  Connect a USB keyboard and mouse to your Mac.
  With your Mac turned on and the display open, connect the Mac to the appropriate port on the external display or projector and turn the display or projector on. 
  Use an appropriate Apple video adapter if necessary.
  After your Mac notebook's Desktop appears on the external display, close the computer's lid.
  When you close the lid: 
  In OS X Lion v10.7 and later, the external display changes to a blue screen, then shows your Desktop.
  In OS X v10.6.8 and earlier, you can wake your Mac by clicking the mouse button or pressing a key on the external keyboard.
  


You can now use your Mac notebook as you normally would with a USB keyboard and mouse.