The Python virtual environment cannot be called directly from mayapy. Instead a soft link needs to be made to mayapy from a command called "python" within the same directory, and venv needs to be called from this python command.
On Windows
Open a command window and change directory to C:\Program Files\Autodesk\Maya<VersionNumber>\bin\.
Create a soft link to mayapy from a command named python:
bin> mklink python.exe mayapy.exe symbolic link created for python.exe <<===>> mayapy.exe
Run venv using the python command you linked to mayapy:
bin> python -m venv_dir
On macOS
Open a terminal window and change directory to /Applications/Autodesk/maya<VersionNumber>/Maya.app/Contents/bin/ .
Create a soft link to mayapy from a command named python:
$ ln -s -f mayapy python $ ls -l python lrwxr-xr-x 1 user staff 6 6 Oct 16:29 python -> mayapy
Run venv using the python command you linked to mayapy:
bin> python -m venv_dir
On Linux
Open a terminal window and change directory to /usr/autodesk/Maya<VersionNumber>/bin/.
Create a soft link to mayapy from a command named python:
$ ln -s -f mayapy python $ ls -l python lrwxr-xr-x 1 user staff 6 6 Oct 16:29 python -> mayapy
Run venv using the python command you linked to mayapy:
bin> python -m venv_dir