Under a Black-Scholes framework, the dynamics of the stock price under the risk-neutral measure $\mathbb{Q}$ are given by ...

$$ S_t = r S_tdt +\sigma S_tdW^{\mathbb{Q}}_t $$

... and those of the risk-free bond by:

$$ \begin{align}
dB_t = rB_tdt
\end{align} $$

Let us define the derivative value as $V(t,S_t)$, which only depends on the time $t$ and the stock price $S_t$. For notational clarity we will also write $V_t$. 

Because the value of the derivative only depends on time and stock price, we can form a portfolio made up of $w_S(t)$ shares of stocks and $w_B(t)$ bonds which _replicates_ the derivative's payoff. Because the portfolio replicates the payoff, by no arbitrage both the derivative and the portfolio must have the same value for all $t$ between $0$ and the derivative's maturity $T$:

$$ V_t = w_S(t)S_t+w_B(t)B_t$$

This portfolio needs to be _self-financing_, meaning that the net impact of changes in the allocation $w(t)=(w_S(t),w_B(t))$ must be equal to $0$ $-$ _i.e._ no cash injections into or withdrawals from the portfolio:

$$ dV_t = w_S(t)dS_t+w_B(t)dB_t \quad (1)$$

To ensure property $(1)$ is verified, a trivial strategy is to choose:

$$ w_B(t) = \frac{V_t - w_S(t)S_t}{B_t} $$

Indeed, at each time step you rebalance your portfolio by buying (selling) $w_S(t+dt)-w_S(t)$ shares of stock and selling (buying) bonds in a such a quantity that makes the derivative value and the portfolio value match.

We end up for the following dynamics for the derivative's value:

$$ dV_t = w_S(t)dS_t + r(V_t-w_S(t)S_t)dt \quad (2)$$

Now, consider the dynamics of the discounted stock price. By Ito's lemma:

$$ \begin{align}
d\left(e^{-rt}S_t\right) & = -re^{-rt}S_tdt + e^{-rt}dS_t 
\\[9pt]
& = e^{-rt}\sigma S_tdW_t^{\mathbb{Q}}
\end{align}$$

Hence, as stated in your question, the discounted stock price is a martingale$^1$ under $\mathbb{Q}$. Let us now derive the dynamics of the _discounted derivative value process_ with Ito's lemma again:

$$ \begin{align}
d\left(e^{-rt}V_t\right) = -re^{-rt}V_tdt + e^{-rt}dV_t \quad (3)
\end{align} $$

Now, combining $(2)$ and $(3)$:

$$ \begin{align}
d\left(e^{-rt}V_t\right) & = -re^{-rt}V_tdt + w_S(t)e^{-rt}dS_t + r(V_t-w_S(t)S_t)e^{-rt}dt
\\[9pt]
& = w_S(t)e^{-rt}dS_t - w_S(t)e^{-rt}rS_tdt
\\[9pt]
& = w_S(t)e^{-rt}rS_tdt + w_S(t)e^{-rt}\sigma S_tdW_t^{\mathbb{Q}} - w_S(t)e^{-rt}rS_tdt
\\[9pt]
& = w_S(t)e^{-rt}\sigma S_tdW_t^{\mathbb{Q}}
\\[9pt]
& = w_S(t) \, d\left(e^{-rt}S_t\right)\end{align} $$

The dynamics of the discounted derivative value are drift-less $-$ _i.e._ we only have a term in $dW_t^{\mathbb{Q}}$ left $-$ hence the discounted derivative price is a martingale under the risk-neutral measure$^1$.

----------

_**Technical point** $1$: an Ito process $X_t$ with $0$ drift is strictly speaking a_ local _martingale. A further technical condition is required to ensure that the process is also a martingale: one such possible condition is that the expected quadratic variation of the process must be finite. In general, the local martingales we work with in financial engineering verify this type of condition so we do not bother proving that the local martingale is also a martingale._

_Here, in the case of the discounted stock price:_

$$ \mathbb{E}\left[[S,S]_t\right] = \mathbb{E}\left[\int_0^t\sigma^2e^{-2ru}S_u^2du\right] < \infty$$

_We have:_

$$ \begin{align}
\mathbb{E}\left[\int_0^t\sigma^2e^{-2ru}S_u^2du\right] & = \sigma^2S_0^2 \mathbb{E}\left[\int_0^te^{-2ru}e^{2\left((r-\frac{\sigma^2}{2})u + \sigma W_u\right)}du\right] 
\\[12pt]
& = \sigma^2S_0^2 \int_0^te^{-\sigma^2u} \mathbb{E}\left[e^{2\sigma W_u}\right]du
\\[12pt]
& = \sigma^2S_0^2 \int_0^te^{-\sigma^2u} e^{2\sigma^2 u}du
\\[12pt]
& = \sigma^2S_0^2 \int_0^te^{\sigma^2u}du
\\[12pt]
& = S_0^2 \left(e^{\sigma^2t}-1 \right)
\end{align}$$

_Which is finite for all $t$. For the derivative:_

$$ \mathbb{E}\left[\int_0^t\left(w_S(u)\sigma e^{-ru}S_u\right)^2du\right] < \infty$$

_Conditions over $w_S(t)$ are needed to ensure the expectation is finite. In the case of a European call option, we would have:_

$$ \begin{align}
& w_S(t) = -\frac{\partial V}{\partial S}(t,S_t) = -\mathcal{N}(d_1) < 1
\\[6pt]
& \Rightarrow 0< w_S(t)^2 < 1
\end{align} $$

_Thus the European call price is also a martingale:_

$$ \mathbb{E}\left[\int_0^t\left(w_S(u)\sigma e^{-ru}S_u\right)^2du\right] \leq \mathbb{E}\left[\int_0^t\left(\sigma e^{-ru}S_u\right)^2du\right] < \infty$$