Turn on the Instant Pot to the sauté function. Add olive oil. Once hot, add mushrooms and cook until browned and softened, about 5-7 minutes.
Add onion and garlic and cook until softened, about 3 minutes.
Sprinkle flour over the mushroom mixture and cook for 1 minute, stirring constantly.
Pour in vegetable broth and sherry (if using). Stir well to combine.
Cancel the sauté function. Secure the lid and set the valve to sealing. Cook on manual/high pressure for 5 minutes.
Allow for a natural pressure release for 10 minutes, then carefully release any remaining pressure manually.
Remove the lid and stir in heavy cream. Season with salt and pepper to taste.
Garnish with fresh thyme and serve.