For context, I was fortunate enough to be with DICE during the development of Rally Sport Challenge. I wasn't on the team, but I did get information on development, so I can shed light on the questions in this thread (Just opinions because, obviously, PD is a different team, but racing game AI is generally the same).
Super easy. In fact that's what they do right now (until they are told to change, see below). If you want full race consistency, set up a custom Sophy race correctly and this is what they do for the most part. It's important to point out that this isn't a "script" but an emergent behavior.
What's the difference? A script is exactly that. It will be the same exact behavior every time. Emergent behaviour (as the name implies) emerges from the systems of the AI and it's directives. Coincidentally, I have started to push the emergent behviour in the custom races to see what I can get Sophy to do.
Here's the issue. This is as far from reality that one could get and much more difficulty (to hide) that you think. If you show up at a race IRL, the other competitors don't slow down. YOU have to go faster. Take this year's F1 season. Max didn't get slower, Lando and the McLaren got faster. People want an extremely realistic experience, while also making it as far from realistic as possible, and well, you can see the conflict.
The way Gran Turismo has always operated is that the AI stays (relatively) the same and the player tunes the car to be faster or slower. They set up the "race" to be reflective of how multiplayer (or real life) races play out. The starting position of each driver is a reflection of their skill level. Can you get them to change this behaviour? Yes. Give the back markers faster cars (in custom races) and watch them rip through the field. Their skills "improve" as they gain position.
Why not slow down the AI? You can see this most dramatically with the base AI. It will PARK in the corners. It doesn't flow naturally. Sophy is much better in all regards in terms of behaviour. Making Sophy less difficult means choosing places to obviously slow it down, like the straight, like the braking zones, etc.
This is what the OP is complaining about. Sophy had a lead, and then slowed down to allow the player to catch up. The slowing (the rubber band) is always going to be noticeable.
That's only with the base AI. Sophy doesn't do it.
Throw into all of this the general rules from Sony regarding game shipped for PS5. For instance, players needs to be able to complete the game. I can say that when the PP shipped, some of the 1 and 2 pepper races were impossible for me. It wasn't a show stopper, because you could still complete the game on 0 peppers, but that's why the patch came out so fast. It was likely in process before the PP launched.
So, in short, we need more people in the custom races (and I will bet MY LIFE that PD sees the usage numbers and the race data). IMHO, if we could get a hybrid of Custom Race Sophy and the PP Sophy, I think many of us would be happy. Make Sophy custom race (with boost) fast lap after lap, but maintain those consistent lap times regardless of how far it is from the player. It can be done.