openssl passwd -1 implements UNIX crypt(3) algorithm. The implementation (md5crypt) resides in apps/passwd.c. As a result, the implementation code is not part of thea OpenSSL digest library function. As the function comment says:
MD5-based password algorithm (should probably be available as a library function; then the static buffer would not be acceptable).
So you will not find it in OpenSSLOpenSSL::Digest.
However, you may find other libraries useful, such as unix-crypt.