The most important effect of a venv is to change sys.path, so you should be able to look for that. I’m not sure how to be 100% sure of whether it’s a venv or something else, but the path entries themselves are probably the most important thing in looking for your list of packages anyway.
You could also possibly check sys.executable but I’d be inclined to use sys.path for preference.
If I were you I would study the corresponding specification, or the PEP which is the next best thing: PEP 405 – Python Virtual Environments. Also I think this question has already been asked more than once, but it is true that chances are high that the answers are less than optimal. And in that spirit I will try my luck with my version of a probably less than optimal answer…
If a pyvenv.cfg file is found either adjacent to the Python executable or one directory above it […], this file is scanned for lines of the form key = value. If a home key is found, this signifies that the Python binary belongs to a virtual environment […].