You should be able to do this with rolltemplate logic helpers.
This part is a bit laborious:
Also, if the natural result of the first die equals the second die then it's a critical success if they are both even or a critical failure if they are both odd. This bit isn't crucial though.
but can be done. If this is your own homebrew though, I'd recommend using <5 for failure, and 6+ for success - the code for roll20 is MUCH easier. Using odd and even, you have to repeat each case 5 times because you have to list each number.
The first part is easier but not obvious:
You need to send the roll+bonus, the bonus, and the second roll - set them in your initial template call like
&{template:whatever} [[ [[1d10]] + @{stat} + ?{bonus|0} ]] {{firstroll=$[[0]]}} {{total=$[[1]]}} {{secondroll=[[1d10]]}}
Then in your rolltemplate,
{{#rollTotal() firstroll secondroll}}
<!-- whatever you want to happen when both rolls are equal goes here -->
{{#rollTotal() firstroll 2}}
<!-- put the critical success entry here -->
{{/rollTotal() firstroll 2}}
{{#rollTotal() firstroll 4}}
<!-- put the critical success entry here -->
{{/rollTotal() firstroll 4}}
{{#rollTotal() firstroll 6}}
<!-- put the critical success entry here -->
{{/rollTotal() firstroll 6}}
{{#rollTotal() firstroll 8}}
<!-- put the critical success entry here -->
{{/rollTotal() firstroll 8}}
{{#rollTotal() firstroll 10}}
<!-- put the critical success entry here -->
{{/rollTotal() firstroll 10}}
{{#rollTotal() firstroll 1}}
<!-- put the critical failure entry here -->
{{/rollTotal() firstroll 1}}
{{#rollTotal() firstroll 3}}
<!-- put the critical failure entry here -->
{{/rollTotal() firstroll 3}}
{{#rollTotal() firstroll 5}}
<!-- put the critical failure entry here -->
{{/rollTotal() firstroll 5}}
{{#rollTotal() firstroll 7}}
<!-- put the critical failure entry here -->
{{/rollTotal() firstroll 7}}
{{#rollTotal() firstroll 9}}
<!-- put the critical failure entry here -->
{{/rollTotal() firstroll 9}}
{{/rollTotal() firstroll secondroll}}
{{#^rollTotal() firstroll secondroll}}
<!-- whatever you want to happen when both rolls are NOT equal goes here -->
{{#rollGreater() total secondroll}}
<!-- this is a normal success -->
{{/rollGreater() total secondroll}}
{{#^rollGreater() total secondroll}}
<!-- this is a normal failure -->
{{/^rollGreater() total secondroll}}
{{/^rollTotal() firstroll secondroll}}
Notice that the critical failure and success need to be repeated 5 times because there's no way within a template to check if the roll is odd or even - you have to list every number.
If you change it to be <=5 and >=6 that first section owuld be
{{#rollTotal() firstroll secondroll}}
<!-- whatever you want to happen when both rolls are equal goes here -->
{{#rollGreater() firstroll 5}}
<!-- put the critical success entry here -->
{{/rollGreater() firstroll 5}}
{{#rollLess() firstroll 6}}
<!-- put the critical failure entry here -->
{{/rollLess() firstroll 6}}
{{/rollTotal() firstroll secondroll}}
You can show the natural numbers anywhere by using {{firstroll}} and {{secondroll}}