I don't know of any git command that gives a "bad" exit code, but it seems like an easy way to do it would be to use a git command that gives no output for a file that isn't tracked, such as git-log or git-ls-files. That way you don't really have to do any parsing, you can run it through another simple utility like grep to see if there was any output.
For example,
git-ls-files test_file.c | grep .
will exit with a zero code if the file is tracked, but a exit code of one if the file is not tracked.