It's important to note that the specific case you've mentioned is a bit unusual in regards to what is legal. You're talking about railway workers, and they are covered by a specific law called the Railway Labor Act. ohwilleke touched on this some, but the RLA changes a few things from normal strike rules
Aggregation
Normally, you have one union and one employer involved in any given dispute, but rail carriers operate a complex web of rail lines nationwide. There are 8 rail carriers and a dozen rail unions involved in this rail labor dispute. If even one union goes on strike, all the remaining unions will go on strike in solidarity. In other words, this would potentially be a nationwide shutdown.
Mediation
There's a defined mediation process through the National Mediation Board
Pursuant to the Railway Labor Act, NMB programs provide dispute resolution processes to effectively meet its statutory objectives: avoiding interruption to commerce or to the operation of any carrier; forbidding any limitation upon freedom of association among employees; providing for the prompt and orderly settlement of all disputes concerning rates of pay, rules, or working conditions; and providing for the prompt and orderly settlement of all disputes growing out of grievances related to the implementation and management of collective bargaining agreements.
Unions can be forced into mediation by the RLA. Under the rules of the RLA, no strikes are legal while mediation is going on. If no agreement can be reached, the NMB releases the two sides and that begins a 30-day cooldown process before any legal strikes can be made, which is what happened in 2022
The National Mediation Board (NMB) confirms that, pursuant to the Railway Labor Act, the National Carriers’ Conference Committee (NCCC) and the twelve unions noted below were released by the NMB from statutory Mediation on June 17, 2022, and a 30-day cooling-off period begins on June 18, 2022.
The Presidential Emergency Board
The next step after that would be a Presidential Emergency Board(PEB). President Biden declared one on the day the NMB cooling off period expired. This also prevents any striking for 60 days
By statute, the Executive Order triggers a “cooling off” period intended to keep the parties working toward a negotiated settlement.
The PEB will work with both sides and present a proposal within 30 days. Unions then have another 30 days to vote on the PEB proposal. As noted previously, all unions must accept the agreement or all unions will go on strike. In this case, some unions rejected the PEB deal and President Biden worked directly on massaging the deal further and unions agreed to a further cooling off period to allow members to vote on it
The president was personally involved in the talks, calling into negotiations convened by Labor Secretary Marty Walsh in Washington around 9 p.m. on Wednesday, and pressing both the carriers and the unions to come to an agreement in phone calls this week. Biden had grown animated in recent days about the lack of scheduling flexibility for workers, expressing a mixture of confusion and anger that management was refusing to budge on that point, according to two people who spoke on the condition of anonymity to share details of private conversations with the president.
At least one union rejected the Biden deal.
Congress can impose its own terms
This is where the article that prompted the question comes in. Because a strike appears imminent, Congress can pass a law imposing terms on both sides (either by creating another cooling off period, or accepting terms that most, but not all, unions have accepted). Congress has done this 18 times
Can you still strike?
You can... but not in any official way (i.e. with a traditional picket line). Many states prevent some important public service unions (like police, firefighters, etc) from striking at all. A common response to this would be a "blue flu" (police officers in the US often wear blue uniforms), or "sick-out", where work is intentionally slowed or abandoned almost entirely in a coordinated effort.
Trying to openly defy the government in striking when none is legal often ends poorly for everyone, as it did for the air traffic controller's union in 1981
In striking, the union violated 5 U.S.C. (Supp. III 1956) 118p (now 5 U.S.C. § 7311), which prohibits strikes by federal government employees. Anthony Skirlick of the Los Angeles Center warned that these “Unrealistic demands in the face of this change is suicide". Despite supporting PATCO's effort in his 1980 campaign, Ronald Reagan declared the PATCO strike a "peril to national safety" and ordered them back to work under the terms of the Taft–Hartley Act. Only 1,300 of the nearly 13,000 controllers returned to work.
And
On August 5, following the PATCO workers' refusal to return to work, the Reagan administration fired the 11,345 striking air traffic controllers who had ignored the order, and banned them from federal service for life.