Is metonymy a figure of speech?

Yes, it is.

Metonymy is a figure of speech in which a thing or concept is not called by its own name, but by the name of something closely related to that thing.

Eg :- The pen is mightier than the sword.

Here, the “pen” stands for “the written word”and the “sword” stands for “military aggression and force.”