When the cover is cool, remove it and pull out the old gasket. Clean out the gasket groove in the cover really well. The end of a wooden clothespin covered with a rag works well. Degrease the groove completely.
When you've got the new gasket, apply a small dab of RTV silicon adhesive in the groove at each corner and a few other spots along its length. Not a ton of it, just a small dab that will grab the gasket.
Insert the new gasket into the groove, pressing it in firmly. Then flip the cover over and place it on a flat surface with a weight placed on the cover. Let it sit overnight to let the RTV cure.
The reason to go to all this trouble tap-gluing in the gasket is because it can fall out when trying to replace the valve cover on the engine... or a part of it can, and get pinched when it gets bolted down... defeating everything you set out to accomplish.