Yes, this is quite easy to do with OSMesa, or with EGL_KHR_surfaceless_context. With the latter it will be hardware accelerated too.