Emulating two qubits with a four-level transmon qudit for variational quantum algorithms