It is indeed a scam. If your Apple ID was locked, you will get an email from Apple, not a text. Report the phishing text here.
To report spam or other suspicious messages that you receive through iMessage, please send them to imessage.spam@apple.com.
Identify and report phishing emails and other suspicious messages - Apple Support