In case you would like to edit the source code of the library their repository is made freely available at https://github.com/itseez/opencv.
You can simply download the repository (or issue a pull request using git). In order to find the function for computing the Hamming distance in the source code either use the documentation for more information or simply run a "Find/Search" on the project. In the end make the required source code changes and then compile/build.
The resulting libraries will contain your changes. You can then link your own application to these libraries.