How can we sign a contract digitally between two parties?
No.  Cryptography alone cannot solve this problem.

Solving this problem requires a combination of technical (e.g., cryptography, systems security) and non-technical (e.g., legal, regulatory, contractual) solutions.  Even the technical part is not solely a cryptography question; it as much about systems security.