Hi,
The command you're looking for is analogWrite(pin, value) (link to reference page). That outputs a PWM signal with a defined duty cycle to the specified pin.
How you utilise it in your code will depend on the motor controller you're driving your motor(s) with.
Cheers ! Geoff