Anelastic dynamo models with variable electrical conductivity: an application to gas giants