To expand upon what Adran briefly mentioned, you would need to use the DataCubeService or NativeStructureService entity depending on if if you are using our Data Cubes or a native OLAP structure like SSAS. Then you can get the specific dimension that you want to add to a Metric Set. On that front, the MetricSetService can be utilized to get a specific metric set and modify it to add a new dimension as a slicer.
Something to be aware of here is how to retrieve their Metric Sets in the case you are wanting to update many at once - one option is to add all the Metric Set to a dashboard and run the script from that Dashboard. Other things that should be kept in mind are to make sure those Metric Sets are checked out and that they don’t already include the dimension you are attempting to add.
It’s certainly doable, but it can be complex, so if you need more of a deeper dive or an involved guidance, I would suggest engaging our professional services team as they are best equipped to handle this.