Is there a way to ascertain a pair or more of Bitcoin addresses belong to the same wallet on the basis an address pair was used as input for a single transaction?
Assuming that all inputs to a transaction are from the same wallet is often called the 'common input ownership heuristic', but it is possible to create transactions using inputs from various ...
In your script the previous ScriptPubKey is different.
If you want create custom script you need to sign manually the transaction, you can't use signrawtransactionwithkey. Bitcoin core sign only the standard transaction