I've read at multiple points (e.g. here) that homotopy type theory "models" types as spaces. I can understand informally that we can "think of" types as spaces, in a vague sense. But what is formally meant by a type theory "modelling" something?
When I was taught a course on formal logic (using first order logic and a form of natural deduction) using the book "Mathematical logic by Ebbinghaus, Flum, Thomas", there was a formal semantics of logical propositions, in terms of structures and interpretations. An "interpretation of a first-order logical formula" was formally defined as a set, with mathematical functions corresponding to the symbols classified as "function symbols", similarly for mathematical relations and constants. i.e. "interpretation" has a formal definition (which can be found in that book).
Is there similarly a formal definition of "interpretation of a type theory" written down somewhere?
A type theory models "something" when "something" gives an interpretation of the constructions (terms and types) of the type theory. More generally, a formal theory models "something" when the constructions of the theory can be interpreted by the "objects" of "something".
At the end of the day, we could also say that a theory is a "formal model" of "something": but in practice we never say "A is a formal model of B" but "A models B", or "B is a model of A".
The interpretation is not just "something that you can think of, in a vague sense". A correct interpretation is justified by a systematic study of all possible constructions of the theory: each possible construction must have its own interpretation, functions and relations must have a consistent interpretation. When "something" is also formalized, and not just an intuition, then you should be able to build an interpretation function that converts any construction of the theory into a construction of the model.