user4418: I recently saw this mate-in-2 problem
[title "White to mate in 2"]
[fen "8/8/8/2B5/2p5/1kp5/8/R3K3 w - - 0 1"]

This was posed with the hint that the player of the White pieces was a strong player and Black was a novice. The take away was that White was offering rook odds, started the game without a rook on a1 and the rook now on a1 had started on h1. 
The key was that White castles queenside with the ghost of the rook given as odds so the king moved from e1 to c1 and the rook on a1 stayed where it was. This forces Black to play c2 allowing White to play Ra3 mate.
This raises two questions:

Is castling with a "ghost" rook like this legal where there has
never been a rook on a1 because it was given as odds at the start of
the game?
Is castling with a "ghost" rook like this legal
where there was a rook on a1 at the start of the game but it was
captured before it could move?

The replayer doesn't like it. It will only allow castling with a real rook.

user18809: There are no official rules regarding games with "odds", so I guess it's up to your taste for this particular case. Anyway, my first thought would be to say "No. You can't" and allowing that possibility would be making a strange twist of the rules that should be specified beforehand

user15543: @Remellion suggested in a comment, less than an hour ago, for a directmate joke problem in which the key is to capture a ghost rook in order to prevent ghost castling as a defense.
As such, I decided to make such a problem just for fun. This is what I came up with. The White rook "on a1 must be "captured" first to prevent the White king from casting away from the mating net.
[Title "me, chess.stackexchange.com 9/1/2019, Black Mates In 4"]
[FEN "r6B/1p2p3/8/8/8/3p1k1p/3P4/4K3 b - - 0 1"]

1. Ra1+! Bxa1 2. h2 Bd4 3. h1=Q+ Bg1 4. Qxg1#

I suppose the way these "ghost" rooks are as spectators. They are invisible, can be moved through, and can't interact with other pieces, similar to a ghost. But other pieces can choose to not interact with it by sitting on the square, and a one-time "capture" can be done at any time.
The technicality here is that since the rook is still there, and castling counts is king move. It can be moved without ever moving on its own. As such, interesting problems can be created.
An interesting concept that arises from this definition of a ghost rook is that a piece can capture two enemy pieces on the same square. If White moves a piece to a8 a Black piece can do a "double capture." The player giving the odds may retain their castling rights if they move onto the rook's square. The ghost rook can be “captured” though if an enemy piece is there.
While these rulesets can be applied to any "ghosted" piece, minus the king, the rook is the only interesting case due to the castling possibilities there are to explore.

user10380: No, not really. Some problemists might use your case 1 as a joke, but it's not really legal. Your case 2 is certainly not legal (even if the rook had never moved).

user4418: The second part of the question is more straightforward, so I'll look at that first.

Is castling with a "ghost" rook like this legal where there was a rook
  on a1 at the start of the game but it was captured before it could
  move?

Article 3.8.2 of the FIDE Laws of Chess describes how castling works:

3.8.2 by ‘castling’. This is a move of the king and either rook of the same colour along the player’s first rank, counting as a single move
  of the king and executed as follows: the king is transferred from its
  original square two squares towards the rook on its original square,
  then that rook is transferred to the square the king has just crossed.

This explicitly states that castling involves two pieces, the king and the rook, and it describes how the rook moves in this manoeuvre. If you don't have an unmoved rook on the board then you can't castle. Therefore castling with a "ghost" rook is illegal.
With this clear the first part becomes easier to answer.

Is castling with a "ghost" rook like this legal where there has never
  been a rook on a1 because it was given as odds at the start of the
  game?

It depends on the rules of the competition or individual game, if the game is a one-off. If the rules state that apart from the initial position of the board the FIDE Laws of Chess apply then clearly it is illegal.
In the absence of such a clarification the best guide is probably the chess historian Edward Winter. In his chess notes for March 2009, note 6029 he considers exactly this question:

6029. Castling with a phantom rook From Mark Thornton (Cambridge, England):
‘In rook-odds games could the odds-giver castle with the “phantom
  rook”? For example, if White gave the odds of his queen’s rook, could
  he play Ke1-c1? And, if so, were the castling rules the same as if the
  rook were present?’

According to Winter there is no conclusive ruling one way or the other. He quotes probably the most sensible approach from Howard Staunton on page 35 of Chess Praxis (London, 1860):

When a player gives the odds of his king’s or queen’s rook, he must
  not castle (or, more properly speaking, leap his king) on the side
  from whence he takes off the rook, unless before commencing the game
  or match he stipulates to have the privilege of so doing.

There are strong feelings on both sides of the argument. Here is more from Winter:

However, in a review of the book on pages 88-89 of the March 1890 BCM
  Edward Freeborough disagreed. After stating, with respect to level
  games, that castling should be described as a move of the king and
  that the king should therefore be moved first, Freeborough observed:
‘It follows logically that the fact of giving the odds of a rook
  ought not to deprive the king of his privilege of taking two steps to
  the right or left as his first move.’
Page 36 of The British Chess Code (London, 1903) stated:
‘In the absence of agreement to a different effect, a player may
  castle (by moving his king as in ordinary castling) on a side from
  which, before the commencement of the game, the player’s rook has been
  removed, provided that this rook’s square is unoccupied and has been
  unoccupied throughout the game, and that the same conditions as to
  squares and as to the king are fulfilled which are required for
  ordinary castling on this side.’
The above text was quoted on page 275 of the June 1916 Chess Amateur
  when a revised edition of the Code was envisaged. Comments were
  invited, and on page 305 of the July 1916 issue ‘Simplex’ wrote:
‘This I think sheer nonsense. If a player gave me a rook and wanted
  to castle on this rook’s side, I should say, “No, you don’t, you can’t
  castle without a castle”. Let’s have no pretence. If a player gives a
  rook, let him give it totally not half. Receivers of odds are not
  strong players, and to see the nominal giver of odds move his king a
  couple of squares would be disconcerting. No; if a player gives odds
  let him give them without pretence.’
A contrary view was expressed by W.S. Branch on pages 333-334 of the
  August 1916 Chess Amateur:
‘Re Chess Laws, page 305 (July), and as to “castling without rook”, I
  would say, first, that you can’t “castle the king” – the full and
  proper term, of which “castles” is an abridgment – without a castle.
  The phrase should be “moving the king as in castling”. I believe that
  the right of the odds-giver to move his king, once in a game, as in
  castling, has always been upheld since “castling” was invented
  (sixteenth century). It existed, as part of the “king’s leap”, long
  before “castling” was invented, and long before the rook was ever
  called a “castle”. The giving of the rook as odds should not deprive
  the king of any of his rights.’
Branch then gave further historical details regarding the king’s leap.
  By 1916, however, the practice of giving odds was disappearing,
  without any formal resolution of the ‘phantom rook’ question.

Winter revisits this topic in note 6035. "Castling with a phantom rook (C.N. 6029)" with some interesting anecdotes regarding castling with a ghost or phantom rook.

4418: <p>I recently saw this mate-in-2 problem</p>

<pre><code>[title "White to mate in 2"]
[fen "8/8/8/2B5/2p5/1kp5/8/R3K3 w - - 0 1"]
</code></pre>

<p>This was posed with the hint that the player of the White pieces was a strong player and Black was a novice. The take away was that White was offering rook odds, started the game without a rook on a1 and the rook now on a1 had started on h1. </p>

<p>The key was that White castles queenside with the ghost of the rook given as odds so the king moved from e1 to c1 and the rook on a1 stayed where it was. This forces Black to play c2 allowing White to play Ra3 mate.</p>

<p>This raises two questions:</p>

<ol>
<li>Is castling with a "ghost" rook like this legal where there has
never been a rook on a1 because it was given as odds at the start of
the game?</li>
<li>Is castling with a "ghost" rook like this legal
where there was a rook on a1 at the start of the game but it was
captured before it could move?</li>
</ol>

<p>The replayer doesn't like it. It will only allow castling with a real rook.</p>
 18809: <p>There are no official rules regarding games with "odds", so I guess it's up to your taste for this particular case. Anyway, my first thought would be to say "No. You can't" and allowing that possibility would be making a strange twist of the rules that should be specified beforehand</p>
 15543: <p>@Remellion suggested in a comment, less than an hour ago, for a directmate joke problem in which the key is to capture a ghost rook in order to prevent ghost castling as a defense.</p>
<p>As such, I decided to make such a problem just for fun. This is what I came up with. The White rook &quot;on a1 must be &quot;captured&quot; first to prevent the White king from casting away from the mating net.</p>
<pre><code>[Title &quot;me, chess.stackexchange.com 9/1/2019, Black Mates In 4&quot;]
[FEN &quot;r6B/1p2p3/8/8/8/3p1k1p/3P4/4K3 b - - 0 1&quot;]

1. Ra1+! Bxa1 2. h2 Bd4 3. h1=Q+ Bg1 4. Qxg1#
</code></pre>
<p>I suppose the way these &quot;ghost&quot; rooks are as spectators. They are invisible, can be moved through, and can't interact with other pieces, similar to a ghost. But other pieces can choose to not interact with it by sitting on the square, and a one-time &quot;capture&quot; can be done at any time.</p>
<p>The technicality here is that since the rook is still there, and castling counts is king move. It can be moved without ever moving on its own. As such, interesting problems can be created.</p>
<p>An interesting concept that arises from this definition of a ghost rook is that a piece can capture two enemy pieces on the same square. If White moves a piece to a8 a Black piece can do a &quot;double capture.&quot; The player giving the odds may retain their castling rights if they move onto the rook's square. The ghost rook can be “captured” though if an enemy piece is there.</p>
<p>While these rulesets can be applied to any &quot;ghosted&quot; piece, minus the king, the rook is the only interesting case due to the castling possibilities there are to explore.</p>
 10380: <p>No, not really. Some problemists might use your case 1 as a joke, but it's not really legal. Your case 2 is certainly not legal (even if the rook had never moved).</p>
 4418: <p>The second part of the question is more straightforward, so I'll look at that first.</p>

<blockquote>
  <p>Is castling with a "ghost" rook like this legal where there was a rook
  on a1 at the start of the game but it was captured before it could
  move?</p>
</blockquote>

<p>Article 3.8.2 of the <a href="https://www.fide.com/component/handbook/?id=208&amp;view=article" rel="noreferrer">FIDE Laws of Chess</a> describes how castling works:</p>

<blockquote>
  <p>3.8.2 by ‘castling’. <strong>This is a move of the king and either rook</strong> of the same colour along the player’s first rank, counting as a single move
  of the king and executed as follows: the king is transferred from its
  original square two squares towards the rook on its original square,
  <strong>then that rook is transferred to the square the king has just crossed</strong>.</p>
</blockquote>

<p>This explicitly states that castling involves two pieces, the king and the rook, and it describes how the rook moves in this manoeuvre. If you don't have an unmoved rook on the board then you can't castle. Therefore castling with a "ghost" rook is illegal.</p>

<p>With this clear the first part becomes easier to answer.</p>

<blockquote>
  <p>Is castling with a "ghost" rook like this legal where there has never
  been a rook on a1 because it was given as odds at the start of the
  game?</p>
</blockquote>

<p>It depends on the rules of the competition or individual game, if the game is a one-off. If the rules state that apart from the initial position of the board the FIDE Laws of Chess apply then clearly it is illegal.</p>

<p>In the absence of such a clarification the best guide is probably the chess historian Edward Winter. In his <a href="http://www.chesshistory.com/winter/winter56.html" rel="noreferrer">chess notes for March 2009</a>, note 6029 he considers exactly this question:</p>

<blockquote>
  <p><strong>6029. Castling with a phantom rook</strong> From Mark Thornton (Cambridge, England):</p>
  
  <p>‘In rook-odds games could the odds-giver castle with the “phantom
  rook”? For example, if White gave the odds of his queen’s rook, could
  he play Ke1-c1? And, if so, were the castling rules the same as if the
  rook were present?’</p>
</blockquote>

<p>According to Winter there is no conclusive ruling one way or the other. He quotes probably the most sensible approach from Howard Staunton on page 35 of Chess Praxis (London, 1860):</p>

<blockquote>
  <p>When a player gives the odds of his king’s or queen’s rook, he must
  not castle (or, more properly speaking, leap his king) on the side
  from whence he takes off the rook, unless before commencing the game
  or match he stipulates to have the privilege of so doing.</p>
</blockquote>

<p>There are strong feelings on both sides of the argument. Here is more from Winter:</p>

<blockquote>
  <p>However, in a review of the book on pages 88-89 of the March 1890 BCM
  Edward Freeborough disagreed. After stating, with respect to level
  games, that castling should be described as a move of the king and
  that the king should therefore be moved first, Freeborough observed:</p>
  
  <p>‘<em>It follows logically that the fact of giving the odds of a rook
  ought not to deprive the king of his privilege of taking two steps to
  the right or left as his first move.</em>’</p>
  
  <p>Page 36 of The British Chess Code (London, 1903) stated:</p>
  
  <p>‘<em>In the absence of agreement to a different effect, a player may
  castle (by moving his king as in ordinary castling) on a side from
  which, before the commencement of the game, the player’s rook has been
  removed, provided that this rook’s square is unoccupied and has been
  unoccupied throughout the game, and that the same conditions as to
  squares and as to the king are fulfilled which are required for
  ordinary castling on this side</em>.’</p>
  
  <p>The above text was quoted on page 275 of the June 1916 Chess Amateur
  when a revised edition of the Code was envisaged. Comments were
  invited, and on page 305 of the July 1916 issue ‘Simplex’ wrote:</p>
  
  <p>‘<em>This I think sheer nonsense. If a player gave me a rook and wanted
  to castle on this rook’s side, I should say, “No, you don’t, you can’t
  castle without a castle”. Let’s have no pretence. If a player gives a
  rook, let him give it totally not half. Receivers of odds are not
  strong players, and to see the nominal giver of odds move his king a
  couple of squares would be disconcerting. No; if a player gives odds
  let him give them without pretence.</em>’</p>
  
  <p>A contrary view was expressed by W.S. Branch on pages 333-334 of the
  August 1916 Chess Amateur:</p>
  
  <p>‘<em>Re Chess Laws, page 305 (July), and as to “castling without rook”, I
  would say, first, that you can’t “castle the king” – the full and
  proper term, of which “castles” is an abridgment – without a castle.
  The phrase should be “moving the king as in castling”. I believe that
  the right of the odds-giver to move his king, once in a game, as in
  castling, has always been upheld since “castling” was invented
  (sixteenth century). It existed, as part of the “king’s leap”, long
  before “castling” was invented, and long before the rook was ever
  called a “castle”. The giving of the rook as odds should not deprive
  the king of any of his rights.’</em></p>
  
  <p>Branch then gave further historical details regarding the king’s leap.
  By 1916, however, the practice of giving odds was disappearing,
  without any formal resolution of the ‘phantom rook’ question.</p>
</blockquote>

<p>Winter revisits this topic in note 6035. "Castling with a phantom rook (C.N. 6029)" with some interesting anecdotes regarding castling with a ghost or phantom rook.</p>
