This the kind of thing you are looking for :
Click on the simple sword to attach and remove, click on the figure for animation.
Below is a picture of the blender set up. The “sword” has its origin at 0.0.0 and I played with its rotation until it ended fitting into the hand nicely. Notice that the sword origin is not at the end of the sword but slightly in - so that the "handle will fit into the hand.
Feel free to steal my code for the interaction though it is kind of old.
Stay Safe, gryff