Hmmm… When you use Routing API with instructions then in the response you can find state code of the points where you should make a turn/change direction. But I need to find something more precise.
With for example Turf.js you can define which route points are located inside particular state.
Then in another Routing API call you can query for this route to get its length.
Now you can use starting and ending point to calculate route with Calculate Route endpoint.
It returns points of this route.
Then with pointsWithinPolygon from Turf.js you can check them against each predefined polygons.
In the result it returns points, that can be used to reconstruct a route with Calculate Route endpoint. In the response you should see a distance within one state.
var supportingPoints = []
for (var feature in ptsWithin.features) {
supportingPoints.add({"latitude": feature.geometry.coordinates[0], "longitude": feature.geometry.coordinates[1]})
}