There are programs out there that perform the function that you are seeking, but it is highly recomended that most users do not use them. When Apple created "Clamshell Mode", which is a means to have the computer stay active when closed, they did so in a manner that would ensure that a keyboard be actively connected. This was to help make sure that a running computer would be far less likely to be accidentally slipped into an enclosed case, whereby it may overheat with no suitable ventilation. Yes, I know it's not perfect safety, but they try.
I use Caffeine, ALL THE TIME. However, I know of no setting by which it will still permit the computer to be active while closed. You close the case, and even with Caffeine running and engaged, the MBA goes into sleep. I kinda think that Apple would frown on an app in their App Store circumventing the normal actions of sleep mode and clamshell mode.