I assume it's not about setting up a machine user automatically but about setting those values, right? While it should be possible to create a machine user via the API, it is likely not possible to set those two values.
The request to be able to actively set values that are usually generated automatically often indicates a misunderstanding or misinterpretation of these values.
I believe this or a similar question has been asked recently.
So that leads me to they question: Why would you want set the client id/ client secret?
Hmm, that's a bit tricky. However, credentials rotation shouldn't be too bad. I personally would ask my customers to update their credentials rather than migrating them. However, you have to announce it and give them a grace time..