Can a Catholic formally resign or excommunicate himself?

A person who no longer considers himself or herself a Catholic does not need to resign formally from the Church. At most it is only necessary is to formally associate with another denomination or non-Christian religion. If you do not wish to commit to a particular religion, or if you have decided that God does not really exist, then no action is necessary.

If, however, you wish to have your name removed from the baptismal records, you may write to the church and request this. You will receive a reply in which you will be asked to attend a meeting with the church authorities. The purpose of that meeting will be to pressure you into reversing your decision and you may well decide not to attend. However, you must reply, reaffirming your decision, otherwise the church will take no action. In due course, you should receive a communication stating that you are no longer considered a Catholic.
There are two very separate issues: resignation and excommunication.
1) Resignation
A person cannot 'resign' from being a Catholic by doing something such as sending a letter requesting removal from the Baptismal register; Church authorities will not remove a name because it would be to deny that the act of Baptism ever took place. However, regarding marriage, canon 1124 states:
"Without express permission of the competent authority, a marriage is prohibited between two baptised persons of whom one is baptised in the Catholic Church or received into it after baptism and has not defected from it by a formal act and the other of whom is enrolled in a Church or ecclesial community not in full communion with the Catholic Church."
The fact Canon Law recognises that someone may defect from the Catholic Church by a formal act (e.g. joining another church) clearly indicates that a person may leave Catholicism by simply joining another denomination or religion.
2) Excommunication
Excommunication is different from leaving the Catholicism; it means that a person may not receive any of the sacraments of the Church (apart from Reconciliation i.e. confession); however, the individual remains a member of the Church, albeit not one who is in good standing.
Canon 1323.1 restricts excommunication to those over 16 years of age and lists several situations when excommunication cannot be incurred due to such things as pressure, mental incompetence or an act done in ignorance. Canon 1342.1 expressly forbids an excommunication being regarded as permanent. A very few acts incur automatic excommunication e.g. having, performing or assisting in an abortion. (Canon 1398). See related link.
The teaching of the Catholic Church is based on Scripture. According to Scripture a person is born into the Kingdom of Heaven through spiritual birth in Baptism. This cannot be denied or revoked as is made clear when John the Baptist "....saw many of the Pharisees and Sadducees coming for baptism, he said to them, "You brood vipers! Who warned you to flee from the wrath to come? Bear fruit that befits repentance." (Matthew Ch 3) and when Jesus said "Truly, I say to you, among those born of women there has risen no one greater than John the Baptist; yet he who is least in the kingdom of heaven is greater than he. From the days of John the Baptist until now the kingdom of heaven has suffered violence, and men of violence take it by force "(Matthew Ch 11)
Catholics regard the pope as the successor of St Peter and according to the Gospel of St. Matthew (Ch 16) Jesus gave the keys of the Kingdom of Heaven to Peter alone. Like any key-holder the role of Peter and his successors is to provide access to the benefits of the Kingdom of Heaven for those authorised to receive them ("feed my lambs." "feed my sheep").
The excommunication discussion is quite interesting concerning eternal truth. Some Catholics in the past were excommunicated for saying they believed in things that the church did not teach - such as the sun being the centre of the solar system and the planets going round it. We laugh at such beliefs now but what happened to the people who were excommunicated for their enlightenment?
If someone is excommunicated for believing something that the church would now treat as truth why excommunicate anyone? As science advances so does the church's teaching - not quite at the same speed but it does raise issues for ordinary people.
If humans have souls and we can trace our ancestry back to primitive beings then were the souls given at a stroke, later on in human development or did we have them from the outset?" At which point there is problem of different branches of the same family chimpanzees, gorillas, orangutans and the wide variety of great apes also having souls. Of course if we go back further our common inheritance from creeping things would give even more creatures souls.
Answer: Clarification to the statement above regarding souls. Catholicism is possibly the only Christian denomination (apart from Eastern Orthodoxy)which regards animals as having souls, but these souls are considered to be finite. As for humans, Catholicism - like all Christian groups - regards these souls as being immortal; in other words, the human soul continues after the body dies. Catholicism also has no difficulty in accepting evolution as this does not detract from God's creative power. However, Catholicism who hold to what is termed "interventionist evolution"; this means that God intervened in the process of evolution to gift humanity with an immortal soul.

NB - people were not excommunicated for believing things that were emerging as scientific advancements in astrology and such, they were excommunicated for teaching without first having their finds confirmed and for disobedience. Church doctrine has never changed; the earth centric model was never a doctrine of the Catholic Church.

Catholic Answer

A Catholic cannot "resign", it is called "apostasy: when a baptized person entirely gives up his Christian faith. To the second, yes a person can excommunicate himself; certain crimes carry a latae sententiae (automatic) excommunication. Among the later would be an apostate from the faith, a heretic, or a schismatic: all would incur a latae sententiae excommunication. There are, I believe, five other crimes which carry the same sentence - desecrating the Sacred Species, assaulted the Holy Father, procuring or participating in an abortion, etc..
Please note that the teaching of the Catholic Church is NOT based on Scripture. If you read and know history, you will realize that the New Testament Scriptures are based on the Catholic Church, not the other way 'round. The Scriptures were written by members of the first generation of Christians, and were approved and brought together as the New Testament around 380 A.D. by the Council of Rome and Pope Damasus.