I mostly followed this tutorial to get myself set up since I'd never programmed a pico before. I used the same basic circuit but added pwm control and a chunky if-elif-else block to handle the speed control. Works pretty much as intended, see video of Erwin having some fun below.

import utime
import random
import math
from machine import Pin, PWM

motor1a = Pin(14, Pin.OUT)
motor1b = Pin(15, Pin.OUT)

vel = 0
num_steps=3
step_scale=1000

pwm1 = PWM(Pin(14))
pwm2 = PWM(Pin(15))

pwm1.freq(20000)
pwm2.freq(20000)

pwm1.duty_u16(0)
pwm2.duty_u16(0)

#50000 - 60000

while True:
    if vel>60000:
        vel=57000
        pwm1.duty_u16(vel)
        pwm2.duty_u16(0)
        vel=vel+step_scale*random.randint(-num_steps,0)
    elif vel<-60000:
        vel=-57000
        pwm1.duty_u16(0)
        pwm2.duty_u16(-vel)
        vel=vel+step_scale*random.randint(0,num_steps)
    elif vel>49999:
        pwm1.duty_u16(vel)
        pwm2.duty_u16(0)
        vel=vel+step_scale*random.randint(-num_steps,num_steps)
    elif vel<-49999:
        pwm1.duty_u16(0)
        pwm2.duty_u16(-vel)
        vel=vel+step_scale*random.randint(-num_steps,num_steps)
    else:
        pwm1.duty_u16(0)
        pwm2.duty_u16(0)
        vel=50000*random.randint(-1,1)
    print(vel)
    utime.sleep(1)

and of course here's the link to the original toy which, before the motor died was one of our cats' favorite toys: https://www.amazon.com/MOODY-PET-Fling-Ama-String-Cat-Toy/dp/B00IRJ7NL0/ref=sxts_rp_s1_0?cv_ct_cx=Moody+Pet&dchild=1&keywords=Moody+Pet&pd_rd_i=B00IRJ7NL0&pd_rd_r=68c