BOSTON—Emily Brawn stumbled as she attempted to kick opioids a few years ago. When she wasn’t at 12-step meetings, she grew isolated. “Days and days in your own head,” she said. “That is where the relapse starts.”

She is trying a new strategy. In early September, 90 days sober, the 29-year-old stepped into a gym in an industrial corner of Boston. Muscled people were warming up for CrossFit, surrounded by top-line equipment and a rock-climbing wall.

But...