Use Ruby to Generate your Shadow Password
I was initially stumbled on creating the shadow compatible SHA-512 hash.
After a little research, the answer was obvious:
require 'digest/sha2'
password = "pass@123"
salt = rand(36**8).to_s(36)
shadow_hash = password.crypt("$6$" + salt)
And you now have a password hash which you can directly use in /etc/shadow

[...] Pereira, Jude 2012. Use Ruby to Generate your Shadow Password. http://judepereira.com/blog/use-ruby-to-generate-your-shadow-password/ [...]
[...] lib/puppet/parser/functions/hashpw.rb sisältö. Salasanatiivisteen generointi koodi on lainattu Jude Pereiran ja Felipe Ortegan julkaisemista [...]
[...] Pereira, Jude 2012. Use Ruby to Generate your Shadow Password. http://judepereira.com/blog/use-ruby-to-generate-your-shadow-password/ [...]