The Declare Record and Undeclare Record actions are deprecated in SharePoint 2013 Workflow platform, so you will not be able to use them in SharePoint Online since 2010 workflows are no longer supported.
The Record Declaration feature is still available though, which is the most quick and efficient way to lock a document for good.
Activate "In Place Records Management" feature via Site collection features. After that, go to Site Settings > Record declaration settings and select "Block Edit and Delete" under Record Restrictions.
Then go to the document library > Library settings > Record declaration settings and select “Never allow the manual declaration of records”. Also decide if you want to enable “Automatic Declaration”.
If you are open for Power Automate solution, here is a post you can refer to for workaround: SharePoint Online rest api to declare item as record.