Your question is currently under review. Since conversion to .pfx can be labeled as a sensitive operation, we've engage the feature owner to review this case and offer expert guidance. An update will be shared once our investigation is complete.
The typical Azure automation scenario requires importing required module(s) to an Automation account, creating, testing/publishing a runbook for your script.
Might be worthwhile to check out this tutorial on using openssl with PowerShell to see if the same can be applicable to your script to resolve your scenario - assuming your script is authored differently.
Expect an update soon.