You cannot use different stacks in the same project for this purpose, except by wrapping all of the resources in a conditional that selects one target or the other, at which point, you have to acknowledge that there is no relationship between the different stacks. These are different projects.
You can use the same program code and a factory-type pattern to re-use all your non-provider code, and that would work fine in 90% of the code. You'd probably still need a little conditional logic, since it's highly likely that different clouds would use resources in fundamentally incompatible ways (e.g. a "firewall" resource in one cloud might require 10 resources, and it might require 30 resources in another cloud, just because of the underlying technology differences).
Pulumi used to publish a cloud-"(sort-of-)"agnostic provider that wrapped "compute", "storage", "network" etc, and then translated it to Azure/AWS/GCP based on the provider configuration. I never used it, I can't find it in the registry now and I can't even remember what it was called. I guess it's been officially abandoned?
Wrapping "all the things" in a single library is doable, but it's not very maintainable...