This will vary from one university to another. Most universities will allow you to transfer some MS credit from a different university. You will need to consult with the appropriate staff in the PhD program you’re applying to to determine which prior coursework can be applied towards your degree.