You need to use price affecting variants for that. Please see "variants" section in the help page.
The example is given in the product configuration itself. You will reach that screen once you have selected "price affecting variants" in product configuration.