Transition from quantum ergodicity to adiabaticity: Dynamical localization in an amplitude modulated pendulum