Thank you Oscar for the help!
Diffoscope was indeed helpful. Interestingly, objdump and nm would not show any difference between the 2 files on libYAML, but I could find 2 things changing in the file from diffoscope:

The last 2 diff are apparently containing the path to the build folder, so I was able to get rid of this change by setting a fixed build folder on pip with:
I however have no clue what the first diff might be.
In any case, I doubt that I will be able to fix all of our external dependencies this way.
I can think of another alternative, which is to try to prevent pip from building libraries and depending on system libraries.
It is at least possible with libyaml by adding the following option in the requirements.txt file like this:
PyYAML==3.13 --global-option="--without-libyaml"
If I use pip directly, it is then correctly installing PyYAML without libyaml, however sadly the rules_python don't seem to be taking this option into account from the requirements file, _yaml.so is still included in the bazel builds.
I wonder if anyone has handled this situation differently, maybe by manually building the pip modules and including them in the repo?