You are always free to cast a spell regardless of whether a legendary permanent with the same name is already on the battlefield. Casting and the legendary rule are two separate things. Nothing in the rules restricts you from casting a second copy of a legendary creature.
The legendary rule (CR 704.5j) is a state-based action checked continuously while players have priority. It states: if a player controls two or more legendary permanents with the same name, that player chooses one to keep and puts the rest into their owners' graveyards. This happens after the second copy resolves and enters the battlefield, not before or during casting.
So the sequence is: (1) you cast the second copy freely, (2) it resolves and enters the battlefield, (3) state-based actions are checked, (4) you choose which copy to keep and the other goes to the graveyard. Any enters-the-battlefield triggers from the new copy will still happen before it is sacrificed due to the legendary rule.
Example: You control a Thalia, Guardian of Thraben and draw another copy. You may cast it. When it resolves and enters the battlefield, state-based actions trigger the legendary rule — you choose which Thalia to keep, and the other is put into your graveyard. The second Thalia's ETB trigger still resolves first.
This is governed by CR 704.5j (legendary rule as a state-based action) and CR 601.2 (casting a spell), neither of which places any restriction on casting based on existing permanents sharing a legendary name.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.