Welcome to the forums @PepperBoi!
You’ll need to use a Viewport node and then get the ViewportTexture. Check out the viewport folder on the Godot demo repository for some examples on how to use Viewport nodes. In particular, the viewport screenshot example is kinda like what you are looking for.
If you are wanting to just copy the Line2D you’ll need to put it in its own Viewport, set the size to however many pixels you want, add a Camera2D so the Line2D is in view, and then finally get the ViewportTexture using something like $viewport.get_texture()
. Then you can use the ViewportTexture like an ordinary texture, including converting it to an ImageTexture if you want to no longer use/keep the Viewport node.