Search for the chiral magnetic effect through beam energy dependence of charge separation using event shape selection