When filling out a form there is often a field for entering a title (such as Mr, Mrs, etc.). Am I free to put whatever I want in this field or do titles have a legal meaning?
Although your "title" may not of itself have legal force, that doesn't necessarily mean you can do as you please in every situation without fear of liability. For example, if you falsely claim to be a medical doctor or lawyer, you could find yourself liable for civil damages to defrauded clients; you may also violate criminal laws.
(An anonymous bureaucratic form probably won't create that problem, because as another answerer pointed out nobody really cares or pays attention to titles most of the time. But stranger things have happened; and by "form" you could mean "tax form" or some declaration made under penalty of perjury. Lawyers generally avoid blanket "that's fine" answers, because there are almost always many ways that it might not be fine.)
Unsurprisingly, it depends on the country, the title and the form, amongst other things. A similar question focusing on a specific title got closed on Academia SE: Is the title Ph.D. or Dr. meaningless in the sense that anyone can use it? but might contain some interesting pointers.
The Regulated Professions Act restricts the use of title “doctor”, in the context of providing or offering to provide health care to individuals in Ontario, to only those people who are registered with the College of Physicians and Surgeons, Optometrists, Chiropractors, Psychologists and Dentists.
Titles like these have no legal meaning whatsoever - they are only a way of passing on respect to people by knowing their formal title and using it in the future. I am not aware of any government organization that includes your title as part of your legal name.
Having worked in a government organization myself, no verification goes into checking these titles whatsoever. We really couldn't care less - in a huge majority of cases, you're the only one that's ever going to see it anyways so... whatever. We crossed out and ignored a vast majority of them, especially any time someone used Mr, Ms, or Mrs. Most organizations that do record them likely just record them because there's a space for it and you filled it out, then probably never pay attention to it again.
The use of
Dr. is regulated in Germany, as you can see from this article on liberalization to allow American Ph.D.s to use it.
I believe the article is not quite correct: Germany maintains a database of foreign institutions whose doctorates are considered acceptable (to avoid diploma mills?). Not all USA institutions are on it, but all with any significant reputation are.
As you can see from the article, criminal and civil prosecution were considered against highly-qualified American academics, leading to change in the law. I doubt similar lenience would be shown to someone who claimed a spurious degree as a joke.