Objects are either under the control of the animation system-- which includes f-curves and constraints-- or else they are under the control of the physics system. There is no in-between.
If you would like to have an object that copies the Z location of an object, you can disable rendering on your rigid body, then make a new object that copies the Z location of the non-rendering rigid body. Then, you can animate the influence of that constraint, and/or use it in conjunction with other constraints, to control exactly when the object is copying the Z location and, perhaps, when it is copying the XYZ location. I doubt this is what you want, though-- if you switch suddenly to copying XYZ location, the object will jump, because your physics have been moving in XY for a decent chunk of time, ignored by that object.
A different option here, which is what I would recommend considering, is to create non-rendering rigid body physics that act the way you would like them to act. If you want the cube to bounce straight up, then it can bounce off of a level but invisible collider. Or, make an invisible collider wall, to keep the cube from moving in one or more directions. These colliders can have the "animated" trait enabled, allowing you to move them out of the way whenever you want different behavior for your physics. There's no reason that you have to render what your simulation sees.
Colliders aren't the only way you can gain control of a physical system; you can also use animated rigid bodies that are joined to a simulated rigid body via a rigid body constraint.
A final option here is bake your rigid body simulation to keyframes, then edit those keyframes, and then use them as the beginning of a rigid body sequence, during which the cube has the "animated" trait. Any linear or rotational velocity will be recalculated based on the last animated frame.