Each state has a Speed field, but you would need to manually calculate the correct speed for each animation to give the desired duration and manually redo everything if you ever want to make any changes.
You can also link the speed of a state to a float parameter and set it using a script, but there’s no clean way of associating the parameter with the clip to use the clip’s length in your calculation.
As with many animation problems, this one is easily solved by my Animancer plugin (link in my signature). It has a Duration property that does exactly what you want, so you would write something like this:
void PlayIn2Seconds(AnimancerComponent animancer, AnimationClip clip)
{
var state = animancer.Play(clip);
state.Duration = 2;
}
I also just posted an Open Beta for v3.0 a few days ago which has lots of improvements over the version currently on the Asset Store, including lots of new example scenes and much better documentation in general.