Data published as a feature layer must reference a single source geodatabase or database. You cannot publish data from more than one database connection in a single map.
In ArcGIS Pro, if you were to publish the data in a map as a map image and feature layer and there are multiple data sources referenced in the map you will get an error: ‘00062: Map contains data that does not use the same connection to an enterprise geodatabase’.
Web feature layers associated with a map image layer require that all layers and stand-alone tables in the service reference an enterprise geodatabase or a standard enterprise database using a single connection.
Data published only as a map service can come from multiple data sources. While it is possible to enable feature access on a map service after publishing, only the layers from a single data source referenced by the feature service would be accessible.
The requirement is further reiterated in the ArcGIS help documentation referenced from: https://enterprise.arcgis.com/en/server/latest/publish-services/windows/prepare-data-for-feature-services.htm