In S07E10 of The Walking Dead we learn that:
Gabriel did not run away from Alexandria, but was instead kidnapped.
Given that, how did Gabriel manage to write "BOAT" in the notebook?
In short to answer directly: He was able to do this because he did it before he left and dropped the Bible before leaving. And he was not kidnapped, he was captured, but he went there of his own will.
From what I remember:
Gabriel wrote "BOAT" in the book before he left, it was supposed to be a hint as to where he was going, Rick figured that out and knew where to follow him to.
He knew about the place Rick was at with the boat and the storehouse full of stuff (that Rick crossed and took things from).
He was going there with supplies and food (we saw Gabriel gathering things) and it's somewhat implied he knew about those that captured him and had intended to trade food for their troops to help fight. Rick is seen grinning at the large number of people that are there, again implying that he has the same idea as Gabriel - these are just the numbers he needs to fight Negan.
From elsewhere confirming this:
"Why? Well, the only thing Gabriel leaves behind is his bible having written the word 'BOAT' inside - alluding to the vessel Rick and Aaron (Ross Marquand) used at the lake in the midseason finale; the same lake where they were spied on by the very person who spied on Gabriel - the figure who is most likely in the passenger seat."