You can only change the machine type of a stopped instance and an instance is considered stopped only when the instance is in the TERMINATED state. It is not possible to change the machine type of a running instance.
To change a machine type in gcloud, run the following command, replacing INSTANCE with the instance name, and MACHINE-TYPE with the desired machine type:
gcloud compute instances set-machine-type INSTANCE --machine-type MACHINE-TYPE
Your machine type can be a predefined machine type, such as n1-standard-1, or a custom machine type. For example, a custom machine type with 4 vCPUs and 1 GB of memory can be specified as:
For more info refer https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance