Grraarrr! The whole of the blender animation system seems geared up entirely to stop this from being done!
I had an idea - I’d create a second bone for the connection between the two objects, which would be parented to the original one, but not connected. The connection object would then be parented to this new bone, so it would be able to slide in and out, relative to the rest of the armature.
My idea was to drive the movement of this bone according to the rotation of its parent bone. But lo and behold - there is no way of doing this. First I think, “I’ll use the parent bone’s rotation to drive it directly.” But no - you can’t drive a bone with its own armature, for some reason. Then I thought, I know, I’ll parent that bone to an empty, and use the rotation of the empty, but of course, rotation only shows up if it’s relative to its parent, so that didn’t work. The last idea I had was to use a constrain rot on the empty - targeting the parent bone. When I rotate the bone, the empty rotates too, but no! That doesn’t count! I can grab the empty, hit ‘R’ and, although it doesn’t rotate, it will drive the connector as it’s supposed to, but for some reason, when the empty is rotated by the constraint, it’s not allowed.
It’s seriously as if someone decided, “Yeees, let’s make it absolutely impossible for someone to do this.”
I even tried the little python expression box, but blender just says, “Invalid python expression,” for whatever I put in there, almost.