You can try something like this:
<rule name="NON-WWW HTTPS DOMAIN" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="https://www.domain.com/{R:0}" />
</rule>
<rule name="Redirect to domain HTTPS" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^[www\.]*domain\.com$" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.domain.com/{R:0}" />
</rule>
<rule name="Redirect to domain2 HTTPS" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^[www\.]*domain2\.com$" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.domain2.com/{R:0}" />
</rule>
<rule name="NON-WWW HTTPS DOMAIN 2" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain2\.com$" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="https://www.domain2.com/{R:0}" />
</rule>
In order to redirect https://domain.com or https://domain2.com to https://www.domain.com and https://www.domain2.com you need to enable https for: domain.com/www.domain.com and domain2.com/www.domain2.com. It must be enabled in IIS because otherwise IIS will block request for not binded https request and the request will not even be processed by rewrite url.