From my understanding it is not strictly illegal but agents/solicitors acting for a seller who wishes to accept another offer during the transaction process, will have to withdraw from their duties to the client. See more here:
https://www.garringtonscotland.co.uk/gazump-scotland/