This sort of "entrapment" is legal in the US? But maybe they wouldn't care. Anyway, wouldn't it be more useful to invest the time, money and energy in facilitating social integration of these individuals. Just asking.
First off, the vast majority of folks snatched up in these stings end up pleading guilty. It's simple logic, a certainty of spending 20 years in prison is vastly better than the chance of serving a life sentence or being executed.
However, from the strictest legal perspective it's questionable how much the entrapment defense could be used in these cases. From a practical perspective much of this is clearcut entrapment. However, from a legal perspective you have folks who very clearly make strong statements saying they are willing to commit acts of terror and then when presented with the opportunity (in an elaborate masquerade put on by federal agents) they follow through. I can't imagine many lawyers salivating at the prospect of defending that.
No, it's very much illegal in the US. But the government has to show results for all this irrational fear they've inspired so they're not above breaking their own laws and imprisoning mentally unstable people to accomplish their goals.