The answer is yes, you can do it.
From 2001, the Notaries in Spain are connected electronically so they can transfer documents and deeds in real time and with total security. Therefore, if the two parties that have to participate in the signature of a deed are in different locations, the signature can take place as if they were together in the same Notary.
There are two ways of doing that (I will use and example of a purchase deed where one of the parties, the buyer, is in Marbella to purchase a property and the other one, the seller, is in Madrid):
1.- The seller in Madrid signs a power of attorney to someone that is at Marbella so that third person can sign on his/her behalf. The power of Attorney is transmitted in real time and electronically and safely from the Notary in Madrid to the Notary in Marbella so that third person can sign immediately on behalf of the person that is in Madrid.
2.- The purchase deed is signed in Marbella by the buyer and the Notary in Marbella sends that deed in real time, electronically and safely to the Notary in Madrid for the ratification of the seller.
* Since every case is different, if you have to sign a deed with the parties in different locations, please check the different options with your lawyer or notary.
Source: Consejo General del Notariado