If you want to do it that way then you need to use two different source meshes (with the materials applied already), because you cannot switch the material of the instanced meshes. I do something currently with a highlight type mesh, but I will soon be replacing it now that we have instancedBuffers, as I can change the color of the instanced mesh on a per instance basis.
If for some reason you want to do it that way, you just enable or dispose then mesh when you want to switch it out and replace it with the new one. It’s a bit wonky though, and prone to errors. If you are just trying to switch the color, I’d highly recommend using instancedBuffers instead.