Nicola Sturgeon has said a second independence referendum will become a “legitimate, almost necessary” step unless Scotland secures a special relationship with the European Union before article 50 is triggered.