Let us say you have your AnimationTree with the AnimationPlayer set on the anim_player property. And the tree_root of the AnimationTree is an AnimationNodeBlendTree, where - among other nodes - you have an AnimationNodeTransition.
As you are aware, we can get some "paramters" of the AnimationTree, they should appear in the Inspector Panel. And there you should find this one:
$AnimationTree.get("parameters/Transition/current")
Where "Transition" is the name of the node in the AnimationNodeBlendTree. But there isn't a parameter for the xfade_time.
Instead we will get the root of the AnimationTree (in other words, the AnimationNodeBlendTree) like this:
var blend_tree := $AnimationTree.tree_root as AnimationNodeBlendTree
Then we can get the nodes like this:
var blend_tree := $AnimationTree.tree_root as AnimationNodeBlendTree
var node := blend_tree.get("nodes/NodeName/node")
By the way, if you change "/node" to "/position" you get a Vector2 with the position of the node on the editor.
So, let us say we want a node called "Transition", which is our AnimationNodeTransition. We do this:
var blend_tree := $AnimationTree.tree_root as AnimationNodeBlendTree
var transition := blend_tree.get("nodes/Transition/node") as AnimationNodeTransition
And finally we can access xfade_time. Set a random value you said? This should do:
var blend_tree := $AnimationTree.tree_root as AnimationNodeBlendTree
var transition := blend_tree.get("nodes/Transition/node") as AnimationNodeTransition
transition.xfade_time = rand_range(0.0, 120.0)
Or as a one line:
$AnimationTree.tree_root.get("nodes/Transition/node").xfade_time = rand_range(0.0, 120.0)
Be aware that the value of xfade_time is the number of seconds for the transition. So setting 120 give you a two minutes transition.