Unusual interplay between superconductivity and field-induced charge order in YBa2Cu3Oy