Police have taken action after an illegal trap and pony race took place into oncoming traffic in a North Yorkshire road.