Before I go all negative on you...
There are a couple of changes that should make your code "work":
1- You need to bias the input so you can read the negative-half of the waveform. That simply requires two equal-value resistors and a capacitor as shown at the bottom of this post.
For a guitar (high impedance) increase the resistors to 1M or higher. With the higher-value resistors you can (optionally) use a lower-value capacitor of 0.1 or 0.01 uF.
2- Since the analog input is 10-bits and the PWM output is 8-bits, you should divide the values by 4 (or bit-shift right by 2-bits).
3- The default PWM frequency is about 500Hz which is smack-in-the-middle of the audio range and it will overwhelm your actual audio. You need to increase the PWM frequency above the audible range. (I've never done this.)
4- Since the output also can't go negative and it's also biased, you should add a capacitor in series with the output to filter-out the "DC" bias. (Again about 0.1uF will work into a guitar amp).
5- Unfiltered PWM is a "nasty" signal and the the full 0-5V PWM signal is present even with "silence" and it can sometimes do "bad things" to an amplifier! You might want to start-with some cheap powered computer speakers so you don't possibly burn-up your guitar amp.
A low-pass filter can remove the PWM to give you true-analog, but a simple RC filter may not be enough to completely remove the PWM. (You can research that yourself how to make a low-pass filter.)
6- Serial.write() will probably slow-down the loop to the point where you can't properly "sample" the audio. You can use it to make sure you're getting good readings but then take it out (or comment it out) for your "real program".
...Some people have made guitar effects with the Arduino so you might want to Google. Of course you can do more with digital but most regular guitar pedals are analog and depending on what kind of processing you're doing, analog might be better and easier for a DIY project.
Now for the negative...
The Arduino is under-powered for audio processing (slow, not much memory). The ADC is only 10-bits and a little slow for high-frequencies (but probably OK for the guitar). As you know by now, there is no built-in DAC so no true analog-output, and the default PWM is only 8-bits. And, the memory is limited. I wouldn't use an Arduino for audio processing.
I'm not sure how much computing power is needed for various DSP functions, and I don't know how to calculate/estimate that. Changing the volume is simple and distortion can be simple but filtering and other effects can be computationally intensive.
Most DSP requires a known sample rate. Your code doesn't require that because it's reading & writing at the same (unknown) sample rate and you aren't doing anything related to the frequency.
There are specialized DSP chips but they are more expensive and the hardware/software development kits are usually expensive too. A Raspberry Pi might be better than an Arduino. And it's probably best to learn DSP programming on a regular computer.
DSP (digital signal processing) is "advanced programming". If you were studying computer science in college you wouldn't learn DSP until the 3rd or 4th year. The Audacity web site has a little-simple Introduction to digital audio. I have a Digital Audio Programming book but I haven't actually done any audio programming. (I've just been interested in audio & programming for a long time. The book is "generic", not specific to the Arduino.)