Phd at same uni as MSc, possible offer but would like to change topic/group if possible
Two partial answers:


It's not a problem for you to ask Prof. B about the chances of you doing a PhD for him. Even if it is in "secret". You are looking for employment, and you're not obligated to tell prospective employers about the other positions you are looking at. Any professor will assume that their MSc students apply for several (PhD or industry or both) positions, especially if the professor has given them just a "maybe" for continuing with a PhD.
If you get a positive answer from Prof B., I can't imagine there would be a problem saying to Prof. A: "I've been thinking, and I would prefer to do my PhD with Prof. B because I am more interested in researching Topic X, which his/her group is doing". If Prof. A's reaction to that is getting angry, you don't want him/her as your PhD supervisor or collaborator anyway.