Is there a way to run packaged or org tests when we install a Managed/Unlocked SFDX package to an org using
So far you can't. The only thing you can run is Apex Classes compilation with the
However, starting Winter 21, code coverage should be enforced for Unlocked Packages installation.
The original post from PM Dileep Burki is available here, feel free to go there and give your thoughts about it.
Enforcement of Code Coverage in Unlocked Packages
One of the issues many of you have raised in the past is a lack of enforcement of code coverage when it comes to Unlocked Packages. We all know the value of well-written tests when we package Apex. Starting Winter ’21, we want to enforce 75% code coverage. You will be able to create unlocked package versions even if code coverage is less than 75%, but such package versions can only be installed in scratch orgs and non-production orgs. In order to promote a package version from beta to released, you will have to have a minimum of 75% code coverage. You can choose to run code coverage during package version creation by supplying the optional --codecoverage parameter. Starting Summer ’20, in the CLI, we will show a warning that this change is coming. We believe a 4+ month notification is sufficient for you to get prepared for this change. Please let us know your thoughts and comments.