Press Win + R to open the Run dialog. Type gpedit.msc and press Enter to open the Local Group Policy Editor. Navigate to Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown). Double-click on "Shutdown" to open the "Shutdown Properties" window. Click the "Add..." button and browse to select your script or command. Click "OK" to close the windows and apply the policy.
Press Win + R to open the Run dialog. Type regedit and press Enter to open the Registry Editor. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown. Right-click in the right pane, select "New" -> "String Value" and give it a name like "ScriptName". Double-click the newly created value and enter the full path to your script or command as its data.