Find invalid objects in database?
Is there a way to detect that a function is in an invalid state,
  preferably from SQL


For plpgsql, that's the purpose of the plpgsql_check extension.

Otherwise, functions (and now procedures too) can be written in all kinds of languages, so the job of parsing the body of functions is offloaded to these languages. PostgreSQL itself can't know when a function refers to any particular database object: it can't even parse the function's body to start with.

Also, it's arguable that code referencing a not-yet-existing table is necessarily invalid. It may be a temporary table that is meant to always be created before calling the function.


  Can a table in Postgres become invalid after a certain number of
  "dangerous" operations, if so, how would one detect that a table is
  about to enter an invalid state?


When a column is dropped, it's marked as dropped but still uses a slot in pg_attribute and in the heap. If columns are constantly dropped and new columns are constantly added to a table, at some point a row would try to grow bigger than a page, which is forbidden, even though its number of live columns would be reasonable and would cause no problem in a new table. So in a way, you could say that drop column / add column are operations that can make a table unusable, when used recklessly.

There are certainly other corner cases like that, and every case would need its own detection mechanism.


  I guess what I'm trying to find out how I can detect if there are any
  invalid objects in the database before discovering it in run-time.


Framed like that, the question looks too general. In general, objects don't have  a valid flag, with some exceptions such as indexes ith pg_index.indisvalid