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$.
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: the expected quadratic variation of the process must be finite. 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:
$$ w_S(t) = -\frac{\partial V}{\partial S}(t,S_t) = -\mathcal{N}(d_1) \leq 1$$
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$$