How to set only specific nginx server block into maintenance mode programmatically

Option 1 is the best choice. If additional file request bothers you (although there are almost no overhead in it) you can replace it to variable check:

set $maintenance "on";
if ($maintenance = "on") {
    return 503;
}