Similar problem but with the source image. It’s not updating when I set the sprite to something else when the parent object is not active (the source image in inspector is correct though)
try like this
_panel.anchoredPosition3D = new Vector3(_panel.anchoredPosition3D.x, _panel.anchoredPosition3D.y, 0);
…
_panel.anchoredPosition3D = new Vector3(_panel.anchoredPosition3D.x, _panel.anchoredPosition3D.y, .1f);
it works for me