Maybe as an anchored object? I'm not quite clear on what you need to do.
I am setting this sentence within pack copy, and I have this as title before a paragraph. I need to add a box around the text shown, so it matches the pack copy (screenshot)
I think just putting the isolated text into a separate frame, adding a stroke to that frame, and making it an anchored object should do what you need. It's possible you can't get the frame tight enough, though, in which case you might need one more frame to act as a mask. Set the teype in a frame, cut and paste into the mask frame (which has the stroke) and adjust the mask, then anchor that.