I don't believe this is possible out of the box. libgit2 accesses files on the file system, and while you certainly could implement a memory-backed storage as an ODB, I don't think this is implemented by default.
In general, memory-based storage for Git repositories is a lot less useful than you think, because many repositories are large and would consume very large amounts of memory. Even a normal command-line Git process (or libgit2) can map large amounts of memory to read packs and work with objects, so that leaves you with substantially less memory to store data entirely in RAM.
If your goal is to simply improve performance, you can mount a ramdisk on your system and clone a repository to that. How you do that is dependent on your operating system; on Linux, the file system type is tmpfs
.