user29731: If a player grabs a piece to move it, and before placing it in its new position, the player gets second thoughts about the best position for the piece, and so they decide to think a little bit more. While they are thinking and holding the piece, they get an urge to visit the bathroom. In that case, is it legal for the player to take the piece to the bathroom until they are back to resume the game? This assumes that the player will never let go of the piece throughout the entire process until it's placed in its new position.

user12523: A tangential point related to what I think is a misconception behind the question:

This assumes that the player will never let go of the piece throughout the entire process until it's placed in its new position.

It looks like the motivation for the question is the idea that once you grab a piece you can't let go of it until you make your move. What the FIDE rules actually say is (emphasis added):

4.7 When, as a legal move or part of a legal move, a piece has been released on a square, it cannot be moved to another square on this move.[...]

One might think that releasing the piece back in its original square might constitute an illegal move. But note this other rule:

7.5.1 An illegal move is completed once the player has pressed his clock.[...]

So in principle you could release the piece in as many illegal places as you like as long as you don't press the clock before releasing the piece in a legal square. But since there's also the issue of annoying the opponent, which has been brought up in other answers, I would say that least annoying option if you want to let go of the piece before completing your move is to put it back in its original square.

user9179: From FIDE's arbiter manual: "11.5 It is forbidden to distract or annoy the opponent in any manner whatsoever."
I think picking up a piece and keeping it out of the board for a long time is quite disturbing. As far as I know there's no problem on picking up a piece and placing it back on its original square as long as it's the piece you finally move. Probably some sort of gesture or verbal comment would be advisable, but that would be it.

user4418: There are a number of serious things wrong with what you describe:

While they are thinking and holding the piece

You may hold a captured piece while you think but you may not hold a piece that is part of the current position. Your opponent has a right to a full view of the current position on the board at all times except the second or two it takes you to move. Do this in a tournament and be prepared to be punished. At a minimum expect a warning and likely a time penalty.

In that case, is it legal for the player to take the piece to the bathroom until they are back to resume the game?

No! Do this and you risk forfeiting the game.
From the FIDE Laws of Chess:

11.2.1 The ‘playing venue’ is defined as the ‘playing area’, rest rooms, toilets, refreshment area, area set aside for smoking and other places as designated by the arbiter.
11.2.2 The playing area is defined as the place where the games of a competition are played.
11.2.3 Only with the permission of the arbiter can:
11.2.3.1 a player leave the playing venue,
11.2.3.2 the player having the move be allowed to leave the playing area.

In general the toilets are part of the playing venue but not part of the playing area. If you get up from the board while it is your turn you may move about the playing area (and, for instance, look at other boards) but you may not leave the playing area (go to the toilet, go for a smoke or vape, get a drink, food, etc.) without getting the arbiter's permission. If you do so you will likely forfeit the game for possible cheating.

29731: <p>If a player grabs a piece to move it, and before placing it in its new position, the player gets second thoughts about the best position for the piece, and so they decide to think a little bit more. While they are thinking and holding the piece, they get an urge to visit the bathroom. In that case, is it legal for the player to take the piece to the bathroom until they are back to resume the game? This assumes that the player will never let go of the piece throughout the entire process until it's placed in its new position.</p>
 12523: <p>A tangential point related to what I think is a misconception behind the question:</p>
<blockquote>
<p>This assumes that the player will never let go of the piece throughout the entire process until it's placed in its new position.</p>
</blockquote>
<p>It looks like the motivation for the question is the idea that once you grab a piece you can't let go of it until you make your move. What the FIDE rules actually say is (emphasis added):</p>
<blockquote>
<p>4.7 When, <strong>as a legal move or part of a legal move</strong>, a piece has been released on a square, it cannot be moved to another square on this move.[...]</p>
</blockquote>
<p>One might think that releasing the piece back in its original square might constitute an illegal move. But note this other rule:</p>
<blockquote>
<p>7.5.1 An illegal move is completed <strong>once the player has pressed his clock</strong>.[...]</p>
</blockquote>
<p>So in principle you could release the piece in as many illegal places as you like as long as you don't press the clock before releasing the piece in a legal square. But since there's also the issue of annoying the opponent, which has been brought up in other answers, I would say that least annoying option if you want to let go of the piece before completing your move is to put it back in its original square.</p>
 9179: <p>From FIDE's arbiter manual: &quot;11.5 It is forbidden to distract or annoy the opponent in any manner whatsoever.&quot;</p>
<p>I think picking up a piece and keeping it out of the board for a long time is quite disturbing. As far as I know there's no problem on picking up a piece and placing it back on its original square as long as it's the piece you finally move. Probably some sort of gesture or verbal comment would be advisable, but that would be it.</p>
 4418: <p>There are a number of serious things wrong with what you describe:</p>
<blockquote>
<p>While they are thinking and holding the piece</p>
</blockquote>
<p>You may hold a captured piece while you think but you may not hold a piece that is part of the current position. Your opponent has a right to a full view of the current position on the board at all times except the second or two it takes you to move. Do this in a tournament and be prepared to be punished. At a minimum expect a warning and likely a time penalty.</p>
<blockquote>
<p>In that case, is it legal for the player to take the piece to the bathroom until they are back to resume the game?</p>
</blockquote>
<p>No! Do this and you risk forfeiting the game.</p>
<p>From the <a href="https://handbook.fide.com/chapter/E012018" rel="noreferrer">FIDE Laws of Chess</a>:</p>
<blockquote>
<p>11.2.1 The ‘playing venue’ is defined as the ‘playing area’, rest rooms, toilets, refreshment area, area set aside for smoking and other places as designated by the arbiter.</p>
<p>11.2.2 <strong>The playing area is defined as the place where the games of a competition are played</strong>.</p>
<p>11.2.3 <strong>Only with the permission of the arbiter can</strong>:</p>
<p>11.2.3.1 a player leave the playing venue,</p>
<p>11.2.3.2 <strong>the player having the move be allowed to leave the playing area</strong>.</p>
</blockquote>
<p>In general the toilets are part of the playing venue but not part of the playing area. If you get up from the board while it is your turn you may move about the playing area (and, for instance, look at other boards) but you may not leave the playing area (go to the toilet, go for a smoke or vape, get a drink, food, etc.) without getting the arbiter's permission. If you do so you will likely forfeit the game for possible cheating.</p>
