AFAIK, there's no way to change the connection string in the pbix file, you can check this idea Power BI Designer API and vote it up.
To update the connection string of a published dataset, you can check this API SetAllConnections, note that this API can only be called DirectQuery dataset.