Put ru-mac-dv.el into $SHARE_DIR/emacs/$version/lisp/leim/quail
If Emacs is installed from Homebrew, SHARE_DIR will look like HOMEBREW_DIR/share, which in most cases is either /usr/local/share or ~/homebrew/share
For activation, put the following snippet into your custom.el:
(register-input-method
"russian-md" "Russian-Mac Dvorak" 'quail-use-package
"RU-MD" "ЙЦУКЕН Russian Mac Dvorak layout"
"quail/ru-mac-dv")