Obviously, the clock is part of the game. It isn't illegal to dirty flag in any format, with the except of classical.
In classical it's not so much that it's illegal as that it's effectively impossible. Nearly every classical tournament will feature a thirty-second increment. If I have a decent endgame advantage, then 30 seconds a move should always be enough for me to at least avoid losing. (If it's a complicated, double-edged middlegame, then it wouldn't, but that's not what's meant by "dirty-flagging").
In the days before increment, it's true that there were rules designed to protect against dirty-flagging. If I'm remembering correctly, the USCF rule was that if you were low on time in a position in which a class C player would have a 90% chance of managing at least a draw against a master (given adequate time), then you could claim a draw. Obviously, this led to some difficult judgment calls, and lots of tournament directors found themselves enduring the ire of one player or the other, so as soon as digital clocks became widely available, this rule was ditched, to the considerable relief of anyone whose job was to run a tournament.
Running out of time is part of the game. If you want more time, there are daily games.