How to setup Drush core development environment?
a) Start by reading the following material (if you haven't already):


https://github.com/drush-ops/drush/tree/master/tests/README.md
https://github.com/drush-ops/drush/blob/master/CONTRIBUTING.md


b) Fork the drush-ops/drush repository, so that you can track your work (and eventually start a PR from your fork back to the original repo).

c) Install the local dev environment provided using docker-compose:

git clone https://github.com/stefanospetrakis/drush.git
cd drush
git checkout -b YOUR_BRANCH
docker-compose up -d
docker-compose exec drupal composer install


At this point you have the source code of drush, equiped with tests. You can do your changes and additions to it and commit/push to your fork, as your project evolves.

d) You can test your changes at any time, against the official drush test suite to make sure you didn't break something:

docker-compose exec drupal composer test


e) Additionally, you can test your work in progress inside your own drupal projects, by replacing the standard drush in composer with your own fork, that would need three things:


Adding an extra repository in your Drupal's composer.json, e.g.:

"type": "git",
"url": "https://github.com/stefanospetrakis/drush"

Aliasing the "drush/drush" package, in order to pull from your current working branch in your repo, based on the exact version number found in composer.lock, e.g.:

require "drush/drush": "dev-YOUR_BRANCH as 9.5.2",

Use source (git) for your drush package, e.g.

{
"config": {
    "preferred-install": {
        "drush/drush": "source",            
        "*": "dist"
    }
}


}
Possibly do manual pulls inside the vendor/drush/drush folder in order to get your latest work.


And as @greg_1_anderson mentioned in a separate answer, you will find Drupal Core under the sut directory of drush's source code.

Good luck!

P.S.: Replace https://github.com/stefanospetrakis/drush.git with the URL of your fork of drush-ops/drush repository, this is just an example.