Is a junkyard transmission worth the risk?

These things are a toss-up. A good number (but not a majority) of the salvage yard engines, transmissions, or rear axles I’ve gotten involved with have had an issue of some sort. Some were comparatively minor and others were just that; salvage.

You did not state if the transmission is an automatic or manual but an automatic would be the one that would have a tendency to be more trouble-prone.

I would say that it’s worth a shot depending on the price of the transmission and the amount of labor involved and that’s a maybe at best.
You might check around with some yards that also do installations for what they sell. They often do the install for a nominal fee and if there’s a problem with what they installed then they’re on the hook for a refund or redoing it for free.