Use this script until lock track function not coming in VEGAS.
Lock Track (Toggle)
using ScriptPortal.Vegas;
public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        foreach (Track track in vegas.Project.Tracks)
        {
            if (!track.Selected)
                continue;
            // Determine if all events are already locked
            bool allLocked = true;
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (!trackEvent.Locked)
                {
                    allLocked = false;
                    break;
                }
            }
            // Toggle lock state
            bool newLockState = !allLocked;
            foreach (TrackEvent trackEvent in track.Events)
            {
                trackEvent.Locked = newLockState;
            }
        }
    }
}