Renormalization of phonon frequencies by conduction electrons in layer systems with application to YBa2Cu3O7