Using DALnet, for example,
Code:

on *:NOTICE:*nick is owned:?: .timer -m 1 0 Auto-Identify
alias Auto-Identify {
  if (($fulladdress == NickServ!service@dal.net) && ($network == DALnet) && ($right($server,8) == .dal.net)) {
    .raw IDENTIFY $input(Insert your password for the nick $me,poqs,Password,Input Password)
  }
}

Note: auto-identification is dangerous as there are ways to fool your script into identifying. If you use a script such as this, be very aware of where you are. If you lose your password due to an auto-identification script, you won't get your nick back.