Scotland wants to join Brexit legal battle