Volcanoes National Park is open year-round, and gorilla trekking is possible in every month. Gorillas live in the forest regardless of the weather, and finding them is the rangers' job, not yours. The main considerations are weather, trail condition, and permit availability.
June to September is the long dry season — the best conditions for trekking, with drier forest floors, clearer summit views, and lower risk of being soaked to the skin. This is the peak tourist season for Rwanda generally, and gorilla permits sell out furthest in advance during July and August.
December to February is the short dry season — a second good window with fewer visitors than the June–September peak. Permit availability is generally better.
March to May is the long rainy season — the trails are muddy and the forest wet, but the vegetation is lush and photography can be atmospheric. Permits are easier to obtain. The gorilla trekking is entirely viable; you will just get wet.
October to November is the short rainy season. Conditions are similar to March–May. Some of the high-altitude hikes (Bisoke, Karisimbi) are more challenging in the rain.
Book gorilla trekking permits as far in advance as possible through the Rwanda Development Board. The number of permits per family per day is fixed at eight; with twelve habituated families, that is 96 permits per day in total. They sell out months ahead in peak season.