Would I have no choice but to beg forgiveness from the pope or would I be able to continue ruling? How would this effect politics with my neighbors? Would this cause people to go to war against me?
Why are you asking this as a hypothetical?
King John of England's excommunication and interaction with the papacy of Innocent III is very famous and extensively documented. Do you need advice on finding accessible literature for this case-study?