Error when locking a record in BeforeUpdate trigger

Judging by the exception, I'd say that the problem is that you are running this code on an older version of the api that doesn't support the Approval.lock() method. In a different post, I found that for some reason the code will compile and gives a runtime error.

If for some reason the lock methods weren't intended to work on trigger context variables, the fact is that (at least for now) they do. (Again assuming you are using the correct api version). The following simple example works fine for me:

trigger Account on Account (before update) {
    Approval.lock(trigger.new);
}

Note that I also added a Workflow Rule to the Account object in my org that always runs. It doesn't perform any actions, but it makes sure that the lock works consistently.

./workflows/Account.workflow

<?xml version="1.0" encoding="UTF-8"?>
<Workflow xmlns="http://soap.sforce.com/2006/04/metadata">
    <rules>
        <fullName>True</fullName>
        <active>true</active>
        <description>Always runs</description>
        <formula>TRUE</formula>
        <triggerType>onAllChanges</triggerType>
    </rules>
</Workflow>