On the extremal energies of trees with a given maximum degree