It would be like a reverse gravitational slingshot, in a different way.
There is no way to capture with just 2 bodies - it would have to leave on gthe same hyperbolic orbit that it arrived on. However if it drove by and had a close enough interaction with a third body, like Jupiter, it could lose angular momentum to the planet, resulting in entering an orbit around the Sun. Further gravitational interactions with planets could then smooth that orbit out over time.
Alternately this could be the more straightforward scenario of interstellar object hits planetoid, they merge, and the new combined object is now in orbit.
There is no way to capture with just 2 bodies - it would have to leave on gthe same hyperbolic orbit that it arrived on. However if it drove by and had a close enough interaction with a third body, like Jupiter, it could lose angular momentum to the planet, resulting in entering an orbit around the Sun. Further gravitational interactions with planets could then smooth that orbit out over time.
Alternately this could be the more straightforward scenario of interstellar object hits planetoid, they merge, and the new combined object is now in orbit.