Your project in Xcode can have multiple targets, e.g. iOS, macOS, watchOS etc. so you should be able to have one project with multiple targets, each with their own code. You then build and distribute this as one app with one name.
When a user launches it on macOS, the macOS target launches. When they launch it on an iPhone the iOS target is launched.
For example, I have an app with an iOS and watchOS targets. They're in one Xcode project with one name, and they just launch the appropriate binary on the correct platform.
Sorry if I've misunderstood your issue, but this does seem to be quite simple, no?
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect