This picture shows where it is (note the cylinder head cover has been removed, but you get the idea)...
Have a look at your replacement sensor & you'll see where the screw is part hidden - so using a torx (T20 or T25) just take out the screw, and then pull out the sensor. The new sensor will be fatter than the old one (I'll post a picture tonight of the 2 side by side). BTW only use a genuine BMW sensor - all other ones, no matter how they're sold/packaged are rubbish.
HTH