Yes, this is possible. A friend of mine did something similar. She made sure she guaranteed funding / had secured the new PhD opportunity before actually quitting the old one. If she hadn't made certain she had the new opportunity, I don't think she'd have left the old one. I believe she did this by managing to be quite open and having a conversation with the new potential supervisor about the situation, and discussing her interest in doing a project with them. She may have even identified funding options in advance, or she may have asked them about funding. Basically, she got them on board and the rest went smoothly. Let me know if you want me to ask her anything.