You may bring your own Virtual machine in to Azure. See the methods available here: vm-move-overview
One of the easy method is to prepare it in your local computer or on-premises server using virtualization platforms like hyper-v/vmware/virtual box etc. as per your custom OS requirement first. Then, the VHD image can be uploaded to azure storage. With this image, you can create the same image in Azure Stack Hub.
Reference here: vm-move-specialized
----------
--please don't forget to upvote
and Accept as answer
if the reply is helpful--