Can I switch to a Ph.D. program before I finish my master’s?

Yes, but you need to submit an application, and admission is not guaranteed. Start by talking to faculty and staff of the Ph.D. program that interests you.