[`sed` is a Turing complete language](https://sed.sourceforge.io/grabbag/scripts/turing.txt), it can do anything. Someone even [implemented `dc`, the Unix direct calculator in `sed`](https://sed.sourceforge.io/grabbag/scripts/dc_overview.htm).

Compared to that, getting the line number would be trivial, but while `sed`'s language has ready support to match on line number (like with `12 { actions; }` to run actions on line 12) or *print* the line number (with `=`), none of those would help if you wanted to insert that line number in the result of a `s`ubstitution for instance or more generally insert it in the hold or pattern space.

Short of piping the output of `=` in a separate `sed` invocation as [shown by @pLumo](/a/796542), you're left with incrementing a number by yourself using the kind of technique used by `dc.sed` like in:

```
sed 'x;:1
 s/$/,,0123456789,0/;s/^,/0,/
 s/\(.\),\([^,]*\).*\1\(,*.\).*/\3\2/;/,/b1
 x;G;s/\(.*\)\n\(.*\)/line \2 is \1/'
```

Remember that `sed` was a tool written in the 70s on computers with very limited resources. It was mostly made obsolete by `awk` in the late 70s and of course fully by `perl` in the late 80s where those things are trivially done:

```
awk '{print "line "NR" is "$0}'
perl -ne 'print "line $. is $_"'
```