I am doing some automated configuration of Raspberry Pis. I'd like to do things differently depending on if the OS image flashed was Raspberry Pi OS or Raspberry Pi OS Lite.
I'm assuming you mean on systems you are not installing and then configuring, because the answer would then be pretty simple: Just track which image is being installed and apply that.
So, if this is instead supposed to be applied to systems that have possibly or probably been used already, tackle this as an XY problem by checking the difference in what it is that you are actually concerned with, rather than assuming that those differences can only be because of what image was originally flashed, which for any significant context will be false.
I've looked at /etc/os-release and it seems there's no difference between the Lite and non-Lite systems.
Because there isn't any difference in terms of the OS release; they are both the same except for some configuration and the pre-installed package list. All of the actual packages are from the exact same place, and the package manager on the lite version can be used to install any and all packages available on the full version.
This means that you could take a system installed from the lite version and turn it into something identical to one installed from the full version, and vice-versa. Hence:
systemctl get-default, similar to runlevel, will tell me graphical.target or not.
Yes, but that is not a guarantee of which image was originally installed because all someone has to do to change the default is run a single command.
You could do this first thing on a lite system: sudo systemctl set-default graphical-target and it will work. You may not actually boot to a GUI, but get-default will still say graphical-target.
Note that runlevel under systemd is derived directly from the default target and only exists for backward compatibility. If you know you are applying something to a systemd system, don't use runlevel for anything, it's pointlessly atavistic.
pidof lightdm will tell me if there is a display manager running.
More accurately, this will tell you if lightdm is running. This is not a hard and fast requirement of the full version, you can change the display manager to something else -- not to mention remove them all together and/or set the default target to multi-user and not boot to GUI, as some people choose to (I do this on systems where I decide I might want to use the default desktop at some point but in general do not).
Ideally, I'd like to find evidence in some sort of configuration file or log entry.
There's a good chance there is something like that in the apt logs, or at least could be derived from them if they still contain information from the early life of the universe (so to speak), which I do not think is a guarantee on a system that's already been used to an indeterminate extent.
However, even if you can do this, again presuming the reason is because of potentially real differences you are concerned about between one system or another, the original image used for the install is a very bad of deciding what those differences are. Instead, you should ask about a way to determine those more specific differences (in a new question please!).