As far as I know, you cannot specify a version for the 'parent' project in general with composer. The version of a composer package (here the Magento shop) is even optional, so you could not reliably depend on it:
The version of the package. In most cases this is not required and should be omitted
And a Magento installation is consisting of Magento modules. And these modules have their own versions. Though it would desirable to tell composer "Hey, this module can only be used with version X of Magento", you actually have to make the extension dependent on the other Magento extensions, which seems to have their own versioning scheme (with versions > 100). And probably this is what you actually want, since (I guess) your module code really depends on those Magento core modules.
In the composer.json file of my installation (2.3.1) I found a required package "magento/product-community-edition":"2.3.1"
. It would be tempting to make the module dependent on this, however, this is discouraged:
Do not specify a dependency on meta packages (e.g. product-community-edition).
So it seems you should make your module open for different versions or specify the requirements in a readme file.