The same way you did for previous file, take reference from here :
https://magento.stackexchange.com/questions/112699/magento-2-override-lib-classes
Copy that module and paste in your other website, it should work.
@gaurav_harsh1 There is no clear information, my path /lib/internal/Magento/Framework/Search/Dynamic how to edit in a namespace?
Don't edit the lib file, again we are not editing this core file, we have to ovrride this lib/internal file.
Just copy your module to another Project and run commands.