You can create coupon code via backend.
Steps : Login to backend -> Menu -> Marketing -> Cart Price Rule ->
Add New Rule
Under that Form you will find conditions section, Under That section you can add conditions based on your criteria.
You will see Attribute Drop-down Under Condition section.
If your Attribute not there then, you need to follow step,
Backend Login -> Menu -> Stores -> Products (Attribute section) ->
search your attribute - > Click on that Row
Under that page you will find storefront properties, in that change the value of Use for Promo Rule Conditions to YES .
Run php bin/magento c:f command via Terminal.