Dynamics of a bosonic Josephson junction with an impurity