Change a GameObject's collider

How do you change a GameObject’s collider? It appears that you cannot assign collider (read-only var)?

The collider property is probably declared like that in Component :

public Collider collider{ get{ return GetComponent< Collider >(); } }

That’s why you can directly affect an other collider to it. To achieve that, you need to destroy the current collider if there is one, then add a new one.