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 zero-coupon bond (RFZCB) by:

$$ \begin{align}
& dB_t = rB_tdt 
\\[6pt]
& B_0 = 1
\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 $w_S(t)$ shares of stocks and $w_B(t)$ RFZCB 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) = V_t - w_S(t)S_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) RFZCB 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$.

_**Note** $1$: a diffusion process with $0$ drift is technically a_ local _martingale. Further technical conditions, that we assume fulfilled here, are required to ensure that the process is also a martingale._