I recently was asked this question: "Typically, does the ScrumMaster have stories in any given sprint that track for iteration planning, backlog refinement, or any other sprint/Scrum tracking activities? Or does the ScrumMaster's time fall outside the velocity for the Scrum team?"
These are actually two questions, and there are some interesting assumptions within the topic. First, regarding ScrumMaster activities: Like other process and incidental activities, I do not write stories for them. Examples of these activities are holidays, support, training, and also Scrum process work such as sprint planning and daily Scrums. This includes such ScrumMaster activities as preparing for sprint planning. During sprint planning, each team member lists the time that is not available for development of new functionality (stories). The ScrumMaster will put some more hours in this bucket, probably twice as much as the average team member. An example of a capacity plan is in this picture.
(As an exercise to the reader, what can you say about this team's size?)
The remaining hours, in the "Capacity" column, are available for stories. When a team tasks out stories, and a team member commits to a task, the estimated hours for the task are subtracted from his or her capacity. Team members (this includes the ScrumMaster) can commit to tasks until their available hours reach zero. (All this is assuming that a team writes tasks, finds owners for tasks, and estimates tasks during the sprint planning).
So the short answer is: "No, do not write stories for ScrumMaster activities, nor for other Scrum team member activities, when those activities are Scrum process activities."
The issue of velocity is another question, and its answer follows from the above explanation. That is, only the size of accepted stories count toward velocity, and since a process activity is not a story, this work does not count toward velocity.
Finally, I'd like to make an observation, which is that the title of this article is "Is ScrumMaster Time Tracked in Sprints?" The easy answer to this question would have been that Scrum doesn't require time tracking, neither from team members nor from ScrumMasters. One method of progress tracking is the use of sprint burn-down charts, which work with estimated hours left to use, not with tracked hours.