In version ArcGIS Pro 2.9,3.0 and 3.1 the following structure of a web tool work as intended:
Updm2018
└── TestService.atbx
├ __init__.py
├ MyTestService.py
├ foo.py
└──bar
├ __init__.py
├ real_bar.py
├ file_required_by_baz.json
└─ baz.py
The definition was staged using the StageService function and the .sd file will include the required files.
Note: I also tried using the Save As Offline Service Definition tool:

It is worth to mention that the file MyTestService.py include the imports:
…
import foo
from bar import realbar
from bar import baz
…
Execution of the tool StageService in ArcGIS Pro 3.3.1 generates an .sd file with the following structure (.sd file is just a zip file):
│ manifest.xml
│ serviceconfiguration.json
│ tilingservice.xml
│
├───cd
│ └───updm2018
│ foo.py
│ MyTestService.py
│ TestService.atbx
│
├───esriinfo
│ │ iteminfo.xml
│ │
│ └───metadata
│ metadata.xml
│
└───p30
MyTestService.msd
MyTestService.rltx
MyTestService.tbxThere are missing files required by the tool to properly run:
real_bar.py
file_required_by_baz.json
baz.py
The attached file contains the structure folder and Web Tool to reproduce the issue.
Following the indications of the documentation , it should be possible to do it. As a matter of fact it has been working with out any issue, until this version.