Yes, you can open the window inside the cockpit.
Just dont stare at his glasses for too long.
The windows are installed on a rail, and when the window is opened, the window is wholly removed from the frame, and is rolled to the side on the rail.
There are several schemes to alert the pilot to unlocked windows. Flags, handles, tabs. But there is no device installed to prevent that exact selfie as depicted.
*5 hours later*
2.8k, thanks to a picture I saw on Facebook 30 seconds before I saw the question. I am impressed.
I want to flesh out this answer a little bit.
The common feature with cockpit windows is they are completely removed from the frame. They are heavy, and require some mechanical advantages to move either out of the way, or to lock into the window again.
Is it possible to remove the window during a flight? Yes, but you must overcome the pressure differential pushing the window into the frame. At lower altitudes, this is possible, and a safety feature in situations that obstruct forward vision. If the glass is damaged due to bird strikes or volcanic ash, removing the window prior to landing is advisable.
A truly daring pilot could copy the above photo, but it is only with extensive preparations and training could this be done safely. It is easier to do it with Photoshop.
Cool glasses btw.