This will vary from one university to another. Most universities will not allow you to formally transfer more than a minimal amount of MS credit from a different university, in the same way that they limit transfer credit in undergraduate programs. You will need to consult with the appropriate staff in the PhD program you’re applying to to determine which prior coursework, if any, can be applied towards your degree.