Treaties are arbitrary, free-form agreements between one or more realms. Yes, a realm can sign a treaty with itself, and there are quite a few creative uses for such a treaty, from a (secret) declaration of war to internal politics.
Treaties do not have game-mechanic effects. That also means that their potential is unlimited, anything that can be put into words can be put into a treaty.
Diplomats and Ambassadors
Diplomats are nobles that have declared themselves to be dedicated to managing the relationship between their realm and another. The ruler of the realm can officially recognize the diplomat and appoint them as an official ambassador of the realm. Ambassadors have the power to sign treaties on behalf of their realm.
Diplomats can draft new treaties and can propose treaties to other realms.
Any diplomat can draft a new treaty, but it requires the ruler or an ambassador to sign it.
As soon as a treaty has been signed by one or more foreign realms, only ambassadors can change it. Changing anything in a treaty requires re-signing by all signatories.
In order to propose a treaty to a foreign realm, a diplomat has to be in the territory of the target realm. When he is, an option to propose any treaty that his own realm has already signed will appear in his Politics page. Note that only signed treaties can be proposed, drafts can not. This safeguard ensures that while simple diplomats can write treaties, only ambassadors can take the necessary step to make them available to outsiders.
The only complicated thing about treaties is the signing process. There are various stages in which a signature can be. The basic principle is a signature can be made or withdrawn by ambassadors at any time.
Any change to an existing treaty, including proposing it to new partners, requires all realms that had already signed it to re-sign. After all, they might not be happy with the change or the new partner.
To keep record, realms that previously signed a treaty or explicitly withdrew their signature will still be listed as signatories, with an identification of their non-agreement signature status.