You generally cannot play as a villain in the main Justice League video games; the roster is built around the Justice League heroes and, in some titles, additional heroes, with villains appearing as antagonists or in separate fighting-game rosters rather than as player-controlled villains in the story campaign. The answer depends heavily on which game you mean, because "Justice League games" is not one uniform series, and a few games blur the line through fighting-game modes, DLC, or non-Justice-League DC titles.
Why the answer is "usually no"
Most games carrying the Justice League name are action or beat-'em-up titles in which you control members of the League—Superman, Batman, Wonder Woman, The Flash, Green Lantern, Aquaman, and sometimes others—against villain opponents. The design intent is to let players inhabit the heroes. In these campaigns, villains such as Lex Luthor, Darkseid, Brainiac, or the Injustice Gang are enemies to defeat, not avatars to control.
The clearest examples are the Justice League Heroes action game (2006) and the various handheld and console tie-ins to Justice League animated properties. In these, the playable set is heroic. You might unlock extra heroes, but the campaign framing keeps you on the League's side.
Where the line gets blurry
Two situations cause most of the confusion.
First, fighting games with DC rosters often include villains as fully playable characters. The Injustice series is the prominent case: Injustice: Gods Among Us and Injustice 2 are DC fighting games where you can play as Superman, Batman, and Wonder Woman, but also as Lex Luthor, The Joker, Harley Quinn, Bane, and others. These games are not branded "Justice League" games, and their stories are alternate-universe conflicts, but players reasonably associate them with Justice League characters. If your question is "can I play a villain in a game featuring the Justice League," the answer there is yes—villains are on the roster. If your question is strictly "in a game titled Justice League," the answer is usually no.
Second, DLC and alternate modes occasionally let you control a villain in a limited context, such as a challenge map or a versus mode. These are exceptions within a hero-focused game, not a villain campaign.
The key distinction: roster vs. campaign
The useful way to think about it is to separate who is playable from whose story you follow.
Playable roster: In fighting games and some multiplayer modes, villains can be selectable characters. This is common in DC fighting games. Story campaign: Even when villains are playable in versus or challenge content, the narrative campaign typically casts you as the hero. A villain may be playable in a bonus mode without the campaign letting you be the bad guy.
So "can you be a villain" has two answers depending on which you mean. In a strict Justice League-titled action game, you generally cannot be a villain in the campaign. In a DC fighting game featuring the League, you often can select villains for matches.
What is unknown and what is answerable
Because the query does not name a specific title, edition, or platform, I cannot confirm the exact roster of a particular game. Release dates, DLC availability, and platform-specific differences also change over time, and I have no verified current source for any single title's content as of the reference date. What is stable and answerable is the general pattern: Justice League-branded action games are hero-centric; DC fighting games with League characters commonly include playable villains; and villain play, when it exists, is usually confined to versus, challenge, or multiplayer modes rather than the main hero campaign.
If you can name the specific game—for example, a particular Justice League tie-in, Injustice 2, or a DC fighting title—the answer can be made precise about its roster and modes.